Thanks!
So if I understand it correctly, this macro usage in your snippet:
take 3 as f:
echo f
Gets expanded to this:
var f = 3
echo f
How can we change the same macro, so that it desugars over to this instead?
var x = 3
var f = my_enter(x)
try:
f = 3
finally:
my_exit(x)
Where:
1) x is a private variable inside the macro.
2) f is the only variable that gets exported (and then used within the
statement block), so that the statements in the body can use it.
3) my_enter is a separate function that the user must supply, eg:
eg:
proc my_enter(x: int): int =
echo "my_enter was called"
return x
4) my_exit is a separate function that the user must also supply, eg:
proc my_exit(x: int) =
echo "my_exit was called"