Arc Forumnew | comments | leaders | submitlogin
Macros can now be declared out of order
1 point by akkartik 4576 days ago | 3 comments
I just noticed that this common error has an easy fix:

  Error: "Can't coerce  #(tagged mac #<procedure>) fn"
https://github.com/akkartik/arc/commit/9cb8fe5b61

What do people think? Any implications I haven't considered? Too subversive making macros so late-bound? :)

(Also pushed to anarki: https://github.com/nex3/arc/commit/9b293de24e. But no low-level unit tests there.)



2 points by rocketnia 4576 days ago | link

Does this pay off somehow? Everywhere this lets us say (my-mac a b c), we could have already said (rep.my-mac a b c).

That's not to say there's any better functionality to put in place of this error.

-----

1 point by akkartik 4576 days ago | link

Huh. Somehow that rep trick never occurred to me either.

One of my big motivations for first-class macros was to be able to organize my code in any order. If there's no external constraints it increases the odds that a given snapshot will have some reasonable organization that's easy for newcomers to understand. Any constraints just increase the odds of stale organization. I've ranted before about this: http://arclanguage.org/item?id=15587 (footnote 1); https://github.com/akkartik/wart/blob/master/001organization. If macros can be written in any order, that reduces a lot of my need for first-class macros.

-----

2 points by rocketnia 4575 days ago | link

Sorry to say, but I don't believe any of this actually lets you use macros before they're defined. Calling the macro's rep will just succeed at expanding the macro, not executing the resulting code (and not suppressing expansion and execution of the arguments).

-----