Arc Forumnew | comments | leaders | submitlogin
1 point by shader 3592 days ago | link | parent

So, does anyone know what happened to the hack of macexing (or something like that) the car of a list before evaluating it? Unless it's obviously a macro of course.

Or any other ideas on how to add first class macros to arc?

3 points by fallintothis 3591 days ago | link

Did you mean this discussion?

That didn't seem to be about first-class macros, except for a very narrow special case (granted, it's about modules, which you seem most interested in). If you think about it, macro-expanding the car of a list won't really first-class anything -- you'd still need to do

  (if (mem 'x stuff)
      (push 'y stuff)
      (pull 'y stuff))
instead of

  ((if (mem 'x stuff) push pull) 'y stuff)
because macro-expanding the car above doesn't get rid of the macro literals push and pull, which will cause an error on application. vincenz tried to make ac recognize macro literals, but it still amounted to evaling (at least of macros), which he didn't get working.

The most obvious way to handle this is to straight-out interpret. As the most obvious way, I'd guess that's why first-class macros have the reputation of being difficult to compile, since there will be some cases that need run-time expansion.

As I said, to the best of my knowledge it's still an unsolved problem. The most recent information I can find is old:


2 points by shader 3591 days ago | link

Yes, that was the discussion I was talking about, and I suppose you're correct; it wouldn't really help in most cases.

"As I said, to the best of my knowledge it's still an unsolved problem." Then let's see if we can't solve it ;)

Personally, I think that the advantages in terseness of being able to use first class macros would probably outweigh the slight decrease in performance for edge cases.

Couldn't you use the current system, but if the car is a list, eval it, since you don't know what it is yet? That would only add a performance penalty for complex cars.

Maybe the complex car structures could start with a symbol that signifies that it returns a macro, and otherwise it isn't evaled and the performance penalty isn't incurred.

I.e. add a special form that transforms a function call into a macro call, such as (callmac fn). Then functions and macros could be the same, but you just call them differently. ssyntax could then be used to make it look nicer.


1 point by akkartik 3592 days ago | link

I'm not sure what you're referring to in the history of arc..

Eight has first-class macros ( but the author seems to agree with fallintothis ( that it's hard to build a compiler for eight as a result.


1 point by fallintothis 3591 days ago | link

the author seems to agree with shader

Shh, you'll blow my cover!


1 point by akkartik 3591 days ago | link

Oops :)