Arc Forumnew | comments | leaders | submitlogin
3 points by fallintothis 3836 days ago | link | parent

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 3836 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.