diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-06 18:42:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 11:42:43 +0100 |
commit | 9fd67958b97c0254c3b4d8762a7003e317ec21bb (patch) | |
tree | e296a007d3b70627fae630db12101bfb04a0274c /lib | |
parent | 218ff27b70c05340069d262204f785290467aa00 (diff) | |
download | Nim-9fd67958b97c0254c3b4d8762a7003e317ec21bb.tar.gz |
follow #11707(add pragmas examples for =>) (#15863)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/sugar.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index d0f85ad17..46dbb1ece 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -57,12 +57,22 @@ proc createProcType(p, b: NimNode): NimNode {.compileTime.} = macro `=>`*(p, b: untyped): untyped = ## Syntax sugar for anonymous procedures. + ## It also supports pragmas. runnableExamples: proc passTwoAndTwo(f: (int, int) -> int): int = f(2, 2) doAssert passTwoAndTwo((x, y) => x + y) == 4 + type + Bot = object + call: proc (): string {.nosideEffect.} + + var myBot = Bot() + + myBot.call = () {.nosideEffect.} => "I'm a bot." + doAssert myBot.call() == "I'm a bot." + var params = @[ident"auto"] name = newEmptyNode() |