Aaron Sherman wrote:
I can imagine how you would define the constructor on the receiving type
in Perl 6, but there's no "casting" syntax in Perl 6. Should we pretend
there is for purposes of defining a conversion and allow:

        class foo {
                ...
                sub prefix:IO::Socket(foo $f) returns(IO::Socket) {...}
        }

or did Larry mention a way to define a converter and I missed it?

From A12:

**************************
New Grammatical Categories

The current set of grammatical categories for operator names is:

    Category                            Example of use
    --------                            --------------
    coerce:as                           123 as BigInt, BigInt(123)
    self:sort                           @array.=sort
    term:...                            $x = {...}
    prefix:+                            +$x
    infix:+                             $x + $y
    postfix:++                          $x++
    ...
**************************

It's not exactly clear how that's used, considering that you can't do multi-dispatch on the return type (right?)...perhaps like

    multi sub coerce:as(Int $dest is rw, MyObj $src) {...}

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.

Reply via email to