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

Re: User-defined infix subs/methods?

Thread Previous | Thread Next
From:
Ingo Blechschmidt
Date:
July 13, 2005 08:50
Subject:
Re: User-defined infix subs/methods?
Message ID:
db3d4v$m42$1@sea.gmane.org
Hi,

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
    # SomeOtherModule.pm will be parsed using the standard grammar,
    # *not* Grammar::Ruby.

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

    use Grammar::Ruby;
    reuse SomeOtherModule


--Ingo

-- 
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About