Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 4429 days ago | link | parent

I'm not sure, but I think R5RS macros ('syntax-rules, 'let-syntax, 'letrec-syntax, maybe others?) walk the whole template code, taking advantage of their knowledge of special forms like 'let to know when a binding is being introduced.

I think Pauan might be referring to that as a missing feature of that quasisyntax form, regardless of whether that actually causes imperfect hygiene.



1 point by Pauan 4429 days ago | link

That's correct. For instance, with proper full hygiene, you could write do1 like this:

  (mac do1 args
    #`(let g ,(car args)
        ,@(cdr args)
        g))
The only change is I removed the w/uniq wrapper: quasisyntax would automatically make g into a gensym. It doesn't currently do that, but it could.

That would make it essentially a fully hygienic system that's vaguely similar to Scheme's macros, but it's much easier to implement, and you can choose to easily break hygiene at any time (by using quote) rather than fussing with syntax->datum.

It's also fully compatible with Arc 3.1 macros[1], and you can freely choose to use quasiquote or quasisyntax, or hell, use both in the same macro!

Of course, this requires you to actually write the macros in that style. Normal quasiquote macros won't gain any benefit from hygiene in this model: you'd need to convert them to use quasisyntax instead (which is quite easy and even mechanical to do).

---

* [1]: That part requires a compiler change, but I think it's an overall good compiler change that can benefit even non-quasisyntax macros. It works correctly in Nu and ar, but not Arc 3.1.

-----