in reply to Re^3: Perl 6 grammar question
in thread Perl 6 grammar question


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.

Replies are listed 'Best First'.
Re^5: Perl 6 grammar question
by ikegami (Patriarch) on Mar 12, 2010 at 09:03 UTC

    This is good as well... But my point was that this is not the same as controlling the parsing itself.

    I know, and it's not always true. In theory, the module could control the parser to create said if/then structure, and that would be great.

    It's even possible to do this in Perl5 using source filters. When you using filters, you need to provide a parser. Seeing as you have to write the parser, you are definitely controlling it.

    What I meant was, take for example 'given', it can be implemented in a module using if/else statements

    Unfortunately, not really. Perl5 is not expendable in that manner without using source filters.

    Filters replace the builtin parser. That means you need to completely reimplement a Perl parser if you want that resembles Perl. That's what Switch does and that's why it's a source of headaches.

    What you actually want is integration into the existing parser, starting with the ability to add keywords. And that's what Perl6 can do.

    * — Perl doesn't differentiate modules from scripts. It's all Perl code.

Re^5: Perl 6 grammar question
by Corion (Patriarch) on Mar 12, 2010 at 08:47 UTC

    Actually no - the syntax of given can not be implemented in Perl through a module1. You can use source filters to rewrite the program, like Switch did, but you will then get all the problems that are associated with source filters.

    1 Discounting Devel::Declare, which for Perl 5.10 tries to allow new keywords through modules.

    Update: Arunbear tells me that Devel::Declare only requires Perl 5.8.1, so modifying the parse process might be possible even there.


      I think your original comment

      The main thing is that you can introduce new keywords, something which is not easy to do otherwise.

      Was a correct way to say it