On Tue, Aug 08, 2006 at 11:42:15 +0000, Luke Palmer wrote:

> I'm not up-to-date on coersion; last I checked it was hand-wavily
> defined.

Currently it's a unary multimethod:

        my $hamburger = $cow.as(Food);

However, the MMD rules are counterintuitive for dispatch rules.

The reason annotation came up is because I felt it shouldn't be a
parameter at all, but a nullary multimethod on the return value:

        my $hamburger = $cow.as :: Food;

Larry had mentioned that &return.signature is basically the
invocation context.

If we do have a n ullary `as` the annotations are essentially
parameters on the anonymous function that is the CPS continuation.
That continuation's signature is used to perform MMD dispatch on
'as' by matching the --> stuff in opposite priority order.

The current problem is:

        12:15 < audreyt> Point is Shape; 3DPoint is Point
        12:15 < audreyt> er I mean Poind3d
        12:15 < audreyt> Point3d
        12:15 < audreyt> you have an object $o
        12:15 < audreyt> you want to get back Point
        12:15 < audreyt> say $o.as(Point).x
        12:16 < audreyt> $o is actually of class Moose
        12:16 < audreyt> Moose has
        12:16 < audreyt> multi method as (Shape)
        12:16 < audreyt> multi method as (Point3d)
        12:16 < audreyt> if we list "as" using the normal MMD rule
        12:16 < audreyt> proto as ($) {}
        12:16 < audreyt> then Point comes in and Shape is selected
        12:17 < audreyt> but we want Point3d
        12:17 < audreyt> not Shape, to win
        12:17 < nothingmuch> isn't .as(Point) going to fail if it
        returns a Shape?
        12:17 < nothingmuch> i mean
        12:17 < nothingmuch> the rules here are reversed
        12:17 < nothingmuch> Point is not a parameter to .as in the
        natural sense
        12:17 < audreyt> it is going to fail only if we consider the
        return type

http://colabti.de/irclogger/irclogger_log/perl6?date=2006-08-08,Tue&sel=359#l545
for more discussion.

-- 
  Yuval Kogman <[EMAIL PROTECTED]>
http://nothingmuch.woobling.org  0xEBD27418

Attachment: pgplKfIqh5Ipr.pgp
Description: PGP signature

Reply via email to