Hacker News new | ask | show | jobs
by poet 5719 days ago
If your language doesn't have Lisp syntax (or more precisely, a lack of syntax entirely) writing macros will be very unpleasant. How are you going to logically think about manipulating the structure of a program that looks like C# or Perl? Macros are already difficult enough to get right as is, without introducing the problem of syntax. Those languages don't have macros any more than Python has a lambda.
1 comments

How are you going to logically think about manipulating the structure of a program that looks like C# or Perl?

In Perl 6, you extend the active grammar within a delimited scope.

My point still holds, just replace manipulating the structure of a program with manipulating the structure of a grammar. In no way is that comparable to manipulating raw parse trees.
But you are manipulating parse trees: surely you have to add new grammar rules to the parser, but then the macro itself does just that.

Furthermore, when adding syntax you are not limited to a Lisp-style grammar.

Furthermore, when adding syntax you are not limited to a Lisp-style grammar.

You aren't limited to Lisp-style grammar in Lisp either. You can write reader macros if you have to. The point is, that on a basic level manipulating s-expressions is far easier to think about than manipulating the syntax of whatever the flavor of the day language is. You're essentially trying to invent reasons why macros in other languages are the same as Lisp macros and it's simply not true.

Lisp macros manipulate Lisp code once it has been read (parsed and tokenized into lists) and sometime before it is executed. That has nothing to do with grammars. Common Lisp also offers a facility to augment or replace the parsing and tokenizing mechanism in an unrestricted fashion.
Furthermore, when adding syntax you are not limited to a Lisp-style grammar

And this is a very good point because you can add things like XML grammar to Perl6: http://github.com/krunen/xml