Sorry for the late response, here is a starting point for a macro you might want import std/macros macro defVal(defVal: typed, p: untyped): untyped = result = p result[^1].add quote do: return `defVal` echo result.repr # Shows the code at compile time this macro emits proc a(i: int): int {.defVal: 100} = if i > 0: return 300 assert a(1) == 300 assert a(0) == 100 Run
- Porting to Nim kaushalmodi
- Porting to Nim PMunch
- Porting to Nim asrp
- Porting to Nim bpr
- Porting to Nim asrp
- Porting to Nim kaushalmodi
- Porting to Nim ElegantBeef
- Porting to Nim asrp
- Porting to Nim asrp
- Porting to Nim asrp
- Porting to Nim ElegantBeef
- Porting to Nim fengkehh
- Porting to Nim asrp
- Porting to Nim asrp
- Porting to Nim ElegantBeef
- Porting to Nim ynfle
- Porting to Nim PMunch
- Porting to Nim cblake
- Porting to Nim PMunch
- Porting to Nim cblake
- Porting to Nim asrp