masak / alma

ALgoloid with MAcros -- a language with Algol-family syntax where macros take center stage
Artistic License 2.0
139 stars 15 forks source link

Code in macro arguments should also be detached, just like code in quasis #495

Open masak opened 5 years ago

masak commented 5 years ago

What #474 did for quasis, we also need to do for macro arguments.

I started to suspect/remember this as I was working on the #116 stuff and really throwing code around. Here's a golfed bit of code showcasing the problem:

$ bin/007 -e='macro sq(x) { quasi { my n = 5; {{{x}}} * {{{x}}} } }; my n = 7; say(sq(n))'
25

We get a hygiene leak there, and get 25 instead of 49, because the n that gets transported into the macro via the argument x isn't being detached.

380 is related; it's talking about putting code back. Here we're talking about pulling code away.