Arc Forumnew | comments | leaders | submitlogin
3 points by almkglor 6055 days ago | link | parent

Not an idiom in other Lisps, but enabled by Arc's ssyntax - the modifier: idiom.

  (breakable:while (< x length)
    (if (foo x)
        (break x))
    (++ x))
The modifier: idiom is simply a macro, modifier, which accepts a single form. This modifier essentially accepts the argument as an expression and modifies how it operates; in the case of the breakable: modifier, it creates a 'break function which exits the expression.

Another modifier in Anarki is the p-m: modifier (which needs you to (require "lib/defpat.arc")); it transforms any function-defining form into a pattern matching form:

  (p-m:mac foo
    ()  ''(the foo)
    (x) `'(the foo is ,x))
A while back I also posted a w/collect and w/mcollect macro form, which also works as a modifier: http://arclanguage.com/item?id=4390 . Macros which accept only a body will generally also work as modifiers, without, umm, modification.