Arc Forumnew | comments | leaders | submitlogin
Overriding macros with lexically-scoped vars, redux
4 points by akkartik 4578 days ago | 1 comment
I periodically go hunting for this trick to override macros with lexically-scoped variables:

http://www.arclanguage.org/item?id=13606

Everytime I'm like, wait, why isn't this in anarki? And I spend an hour or so digging around before I realize why. Hopefully writing this up will fix it in my memory.

The issue is in overriding common macros like with and unless:

  (mac updating (place ? with t unless 'iso . body)
    ..)
(http://arclanguage.org/item?id=12975; https://github.com/akkartik/arc/blob/e93b4121dd/arc.arc#L497)

Now you can't use with in the body. Perhaps that's ok, but you also can't use let because let calls with and all the levels of macroexpansion happen within the same lexical scope. In effect, overriding macros with lexical scope causes lexically-scoped vars to sometimes act like dynamic scope.



2 points by shader 4577 days ago | link

Maybe we could make it so that only a few macros can't be overridden in call position? Like built-ins vs. user macros? Or would it be ok if we just made it so they could be overridden, and just warn people that overriding important macros is likely to have unexpected results?

-----