Arc Forumnew | comments | leaders | submitlogin
2 points by rntz 5618 days ago | link | parent

Fully hygienic macros have now been implemented and pushed to the hygiene branch - w/uniq is no longer necessary. Moreover, this hygiene can be avoided, which makes possible the writing of anaphoric and other macros which deliberately make use of variable capture. All that is necessary is to unsyntax (#,) the variable which is to be captured. 'iflet neatly demonstrates both automatic avoidance of variable capture and the ability to deliberately capture:

    (mac iflet (var expr then . rest)
      #`(let temp #,expr
          (if temp (let #,var temp #,then) #,@rest)))

    (mac aif (expr . body)
      #`(let #,'it #,expr
          ,(if (cddr body)
             `(if #,'it #,(car body) (aif #,@(cdr body)))
             `(if #,'it #,@body))))
Admittedly, in the case of 'aif at least, the "hygienic" way of doing things doesn't give you any more safety than doing it with normal quasiquotes would. However, nothing prevents you from using normal quasiquoting in this case; arc now has the best of both worlds, as it were.