Why can't macros have an arbitrary number of arguments?

You operated on LFE’s AST using elixir?

Yeah, the lfe compiler modules returned things that were pretty easily useable.

Well the LFE AST is very simple, it is a homoiconic lisp after all. In one sense there is no AST. Some even say lisp has no syntax. :wink: Were you using the lisp forms directly or compiling down to core?

1 Like

We didn’t want to add variadic macros when functions cannot be variadic since they are identified by name and arity. It is certainly doable but it would ultimately be inconsistent and messy. It would also push people to use macros only to get the variadic behaviour - making their code more complex than it should be.

Imagine if we had variadic macros since the beginning… and imagine how that would have affected the design of libraries. Not having them pushed the community to rely on lists on most places someone would use a variadic macro, which is arguably a cleaner solution, and the “check all” workaround is used in very few places (one so far?).

The pros of not having variadic macros certainly outweigh the cons from my perspective. Not having a certain feature sometimes is a feature in itself.

Yes, having variadic macros does sort of break Erlang’s functions with a fixed arity. But I felt it was quite lispy and suited macros quite well. And because of its lisp heritage there are already a number of core LFE forms which are variadic so I didn’t feel it was too strange. It also makes it easier and more consistent to implement forms which do by design take a variable number of arguments, for example list*, forms that I don’t consider to be core forms.

It does mean we have a basic difference between macros and functions, but with exported macros they do start to merge.

And I like them. :grinning:

EDIT: Exported macros are fun, for example they allow you to redefine any of the standard macros but still get the original by calling lfe:macro-name.

I was using your forms directly. To be specific I was ‘borrowing’ your parser before I made my own in my LLixer sandbox app on my github. ^.^;