Hacker News new | ask | show | jobs
by chromatic 5719 days ago
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.

1 comments

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