Remove expr/stmt (#5857)
This commit is contained in:
parent
52ff244d5d
commit
000b8afd26
168 changed files with 497 additions and 529 deletions
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
template withOpenFile(f: expr, filename: string, mode: TFileMode,
|
||||
actions: stmt): stmt {.immediate.} =
|
||||
template withOpenFile(f: untyped, filename: string, mode: TFileMode,
|
||||
actions: untyped): untyped =
|
||||
block:
|
||||
# test that 'f' is implicitly 'injecting':
|
||||
var f: TFile
|
||||
|
|
@ -20,20 +20,20 @@ var
|
|||
myVar: array[0..1, int]
|
||||
|
||||
# Test zero argument template:
|
||||
template ha: expr = myVar[0]
|
||||
template ha: untyped = myVar[0]
|
||||
|
||||
ha = 1
|
||||
echo(ha)
|
||||
|
||||
|
||||
# Test identifier generation:
|
||||
template prefix(name: expr): expr {.immediate.} = `"hu" name`
|
||||
template prefix(name): untyped = `"hu" name`
|
||||
|
||||
var `hu "XYZ"` = "yay"
|
||||
|
||||
echo prefix(XYZ)
|
||||
|
||||
template typedef(name: expr, typ: typeDesc) {.immediate, dirty.} =
|
||||
template typedef(name: untyped, typ: typeDesc) {.immediate, dirty.} =
|
||||
type
|
||||
`T name`* = typ
|
||||
`P name`* = ref `T name`
|
||||
|
|
@ -51,7 +51,7 @@ type
|
|||
proc initFoo(arg: int): Foo =
|
||||
result.arg = arg
|
||||
|
||||
template create(typ: typeDesc, arg: expr): expr = `init typ`(arg)
|
||||
template create(typ: typeDesc, arg: untyped): untyped = `init typ`(arg)
|
||||
|
||||
var ff = Foo.create(12)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue