in reply to Perl 6 grammar question

The main thing is that you can introduce new keywords, something which is not easy to do otherwise. If Perl 5.8 had had that feature already, you could have implemented the given keyword as a Perl module.

Of course, having a mutable language is nothing new - Lisp had it 40 (or is it 50) years ago with its macros.

Replies are listed 'Best First'.
Re^2: Perl 6 grammar question
by Anonymous Monk on Mar 12, 2010 at 08:13 UTC
    I didn't know that lisp had it, thanks for mentioning it here. However in Perl 5 we are introducing it through a module(.pm) file which is pretty much different than controlling the parser itself. Apart from lisp and Perl 6 which other language has this feature(Modern languages in wide use today like Python, ruby, Java etc.)

      However in Perl 5 we are introducing [given] through a module(.pm) file which is pretty much different than controlling the parser itself.

      That's wrong on two levels.

      First, all the module does is to flip a switch that controls whether the parser treats given as a keyword or not. feature most definitely controls the parser itself.

      Secondly, it makes no sense to say that adding keywords dynamically is a good thing and to say that adding keywords using a module is a bad thing. It's a contradiction.


        U'r right, but I never implied adding them through a module is bad or adding them dynamically is good. Of course such features, although powerful must be used with caution and judiciously. That is true for any powerful but use-with-caution feature.

        What I meant was, take for example 'given', it can be implemented in a module using if/else statements. Here what you are doing is using existing features of a language to build more abstract features. This is good as well... But my point was that this is not the same as controlling the parsing itself.

        I would not like start a debate on which of them is better. Users are best to decide on that. To put it more appropriately if there is more than a way to achieve it, its better.

      I'm not aware of any "modern" language having that feature, at least outside of the languages without much syntax (Scheme, Lisp derivatives), where it is easy to introduce new forms or which have (real) macros as a built-in language feature.