|
|
|
|
|
by ICWiener
4100 days ago
|
|
Macros will expand into lisp forms, not only expressions. Whether a form is an expression, a declaration or a pattern depends on the surrounding context. I would say that declarations, ... are not syntax but semantic classes. Too bad the conclusion does not offer a glimpse of what would the extension mechanism look like. Still, nice article. |
|
And in this system, patterns are expressions. So "everything is an expression" isn't exactly wrong in this case.
In Scala, you are given full control over both how a name "applies" (i.e. what Foo(...) does when called as a sort of constructor or factory method) and how it matches, in the form of an "unapply" static method that you implement. It seems like a "match" macro in a LISP could desugar a pattern into a program that matches that pattern, the same way the Scala compiler generates code that calls "unapply".