added 'since' template for further stdlib additions

This commit is contained in:
Andreas Rumpf 2019-11-07 12:02:26 +01:00
commit 372b01711e
2 changed files with 5 additions and 1 deletions

View file

@ -48,3 +48,7 @@ when defined(nimlocks):
{.pragma: benign, gcsafe, locks: 0.} {.pragma: benign, gcsafe, locks: 0.}
else: else:
{.pragma: benign, gcsafe.} {.pragma: benign, gcsafe.}
template since(version, body: untyped) {.dirty.} =
when version <= (NimMajor, NimMinor):
body

View file

@ -685,7 +685,7 @@ proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], benign.} =
else: else:
sysFatal(IOError, "cannot open: " & filename) sysFatal(IOError, "cannot open: " & filename)
proc writeFile*(filename: string, content: openArray[byte]) = proc writeFile*(filename: string, content: openArray[byte]) {.since: (1, 1).} =
## Opens a file named `filename` for writing. Then writes the ## Opens a file named `filename` for writing. Then writes the
## `content` completely to the file and closes the file afterwards. ## `content` completely to the file and closes the file afterwards.
## Raises an IO exception in case of an error. ## Raises an IO exception in case of an error.