blob: a4de7159246d69db745bf3e39e8ba3d1343d963a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
discard """
output: '''fish
fish'''
"""
import macros
block:
template init(initHook: proc(s: string)) =
proc dostuff =
var s = "fish"
initHook(s)
dostuff()
init do(s: string):
echo s
block:
macro init(initHook: proc(s: string)) =
result = newStmtList(
newProc(name = ident("dostuff"), body = newStmtList(
newVarStmt(ident("s"), newStrLitNode("fish")),
newCall(initHook, ident("s"))
)),
newCall("dostuff")
)
init proc(s: string) =
echo s
|