lizmat++
Fail is a good word. I didn't want to have to write throws an exception :o|

I don't totally get the concept of { * } so I won't comment whether
defaults working makes sense or not but it's interesting to note that
coercions don't work in a similar fashion:

class A {

    proto method foo(Int() $x) {*}
    multi method foo($x) {

         $x.WHAT.say; #-> Str

    }
}

A.foo('1');
$x gets coerced but the coerced value doesn't travel downstream.

On Wed, Oct 21, 2015 at 11:31 PM, Elizabeth Mattijsen <l...@dijkmat.nl>
wrote:

> ¢
> > On 21 Oct 2015, at 11:50, Lloyd Fournier (via RT) <
> perl6-bugs-follo...@perl.org> wrote:
> >
> > # New Ticket Created by  Lloyd Fournier
> > # Please include the string:  [perl #126417]
> > # in the subject line of all future correspondence about this issue.
> > # <URL: https://rt.perl.org/Ticket/Display.html?id=126417 >
> >
> >
> > The design docs don't specifically say it's meant to work but implies it
> by
> > saying that shared traits can be set in the proto and default value ~~
> > trait (to me).
> >
> > class A {
> >    proto method foo($x = 'foo') {*}
> >    multi method foo($x) {
> >        $x.say;
> >    }
> > }
> >
> > A.foo(); #!> none of these signatures match
>
> Looks like the { * } is overriding anything you’re specified in the
> signature.  Putting anything else in there, does seem to do the right
> thing.  But there is no easy way to dispatch to the other candidate (that I
> know of).
>
>
> > If specifying a default in a proto is wrong it should carp I guess.
>
> Perl 6 doesn’t carp (afaik): but yeah, it should fail  :-)
>
>
> Liz

Reply via email to