develooper Front page | perl.perl6.language | Postings from July 2005

Re: User-defined infix subs/methods?

Thread Previous | Thread Next
Ingo Blechschmidt
July 13, 2005 08:50
Re: User-defined infix subs/methods?
Message ID:

Michele Dondi wrote:
>> Good, I'd forgotten about that.  Which means that it's even harder
>> for someone to compile a module in a "strange" dialect, since they'd
>> essentially have to write their own version of "use" that forces
>> recompilation ("reuse", if you will).  And the harder we make it to
>> write "reuse", the better.
> IIUC this will introduce a certain degree of asymmetry though, in that
> in some sense p6 will be extremely generous in giving users the
> ability to use whatever dialect/syntax modification they like in their
> programs but just at the same time it will try to make it hard for
> them to do so when refactoring code into suitable modules. Ain't it
> so?

no, if I understood Larry correctly, you can of course write a nice
grammar-modifying module, but other modules you use() still use
Perl 6's standard grammar. E.g.:

    use Grammar::Ruby;
    # Ruby syntax from here on:
    proc { |a| puts a + 1 }.call 3    # 4

    use SomeOtherModule
    # will be parsed using the standard grammar,
    # *not* Grammar::Ruby.

If you wanted the compiler to parse using Ruby's
grammar, you'd have to write:

    use Grammar::Ruby;
    reuse SomeOtherModule


Linux, the choice of a GNU | Row, row, row your bits, gently down the
generation on a dual AMD   | stream...  
Athlon!                    | 

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About