On Mon, Aug 29, 2005 at 15:12:44 +0200, TSa wrote:
> HaloO,
> Yuval Kogman wrote:
> >On Mon, Aug 29, 2005 at 13:12:37 +0200, TSa wrote:
> >>Sorry, I believe everything is an operator---or actually operators
> >>are Code subtypes with syntactic sugar. But some operators are usually
> >>not dispatched because the type system manages to produce the same
> >>effect as a real dispatch. But that is an implementation issue.
> >>Conceptually I like to define the semantics of Perl6 in terms of type
> >>and dispatch.
> >I thought so too, but then i was informed that both assignment and
> >method call dispatch are not operators.
> Not even conceptually? That means the wonderfully obvious and intuitive
> strings '=' and ':=' are blocked for plain users unless they mess with
> the grammar and re-compile the part of CPAN that is of interest to them
> with this modified version? What a maintenance nightmare!

Yup =(

I would much rather = was something like this:

        # := in terms of = is just assignment on the container
        multi sub &*infix:<:=> ($lvalue is rw, $rvalue) {
                variable($lvalue) = variable($rvalue);

        # ::= is a macro, btw

        # this is the generic assignment
        multi sub &*infix:<=> ($lvalue is rw, $rvalue) {
                variable($lvalue).setValue($rvalue) # for the variable()
                # call see s12 right before "Submethods"

        # this is nice for the various container types:
        multi sub &*infix:<=> (@lvalue is rw, @rvalue) {
                @lvalue.elems($rvalue.elems); # allocate right amount of 
                for @lvalue Y @rvalue -> $l is rw, $r {
                        $l = $r;

        # this is also nice for optimization... this example is a bit
        # overly verbose, I guess but it demonstrates the point:
        multi sub &*infix:<=> (Int $lvalue is rw, Int $rvalue) {
                my int $value = $rvalue.unboxed_value; # notice that's 'int' 
and not Int

Maybe 'is rw' is enough for enforcing true lvalue context, but that
is just a context modifier, i guess.

As for method invoaction - i do like the special case. In effect the 


part is parsed as a postfix operator.

It makes some sense to think of it as a macro:


is converted into

        apply(<expr>, <bareword>, <params>)

but this doesn't have any elegance, IMHO.

 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me kicks %s on the nose: neeyah!!!!!!!!!!!!!!!!!

Attachment: pgpGU4I2wiBjC.pgp
Description: PGP signature

Reply via email to