as a lisp noob i'm curious what specific sorts of things you could do with first-class macros. perhaps swapping out macros for a given macro call? say in one pass of a program (function) a particular macro call is expanded by macro1, and in the second pass the macro call is expanded by macro2
I'm not exactly an expert on this, but I think it would allow you to put a macro literal in functional position. Right now:
arc> and
#3(tagged mac #<procedure>)
arc> (eval (list and 1 nil 2))
Error: "Bad object in expression #3(tagged mac #<procedure>)"
So if you had theoretical first-class macros, you could do stuff like use backquote to protect a macro you use from being overridden. (This wouldn't be necessary if we had a module system, but that might require first-class macros itself.) So in the (contrived) example below, foo works fine because prs is a function, but bar fails because foo is a macro.
EDIT: Actually, function literals in functional position only works on Anarki. It might be nice to have that fix in the official version.
arc> (mac foo args `(,prs ,@args))
#3(tagged mac #<procedure>)
arc> (mac bar args `(,foo ,@(keep [isa _ 'sym] args)))
#3(tagged mac #<procedure>)
I think first-class macros might be useful in making infix math expansion occur at compile time rather than run time... but I'm not completely sure on that one.
Yes, please. First class macros and the ability to use macros and functions (rather than just their names or definitions) in functional position would be great, and macro names would not have to shadow variable names gobally anymore. In my opinion that is one of the biggest problems with Arc.