added 'since' template for further stdlib additions

This commit is contained in:
Andreas Rumpf
2019-11-07 12:02:26 +01:00
parent f69ee294c8
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.}
else:
{.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:
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
## `content` completely to the file and closes the file afterwards.
## Raises an IO exception in case of an error.