Welcome back jnthn :)

That makes sense. I thought that proto was a magic way to set defaults for
all parameters for all the sigs in a multi dispatch ie don't repeat
yourself. Mostly because:

 perl6 -e 'proto sub test(Str $x){*}; multi sub test($x) { $x.say };
test(Int);'

fails. But it looks like proto is only there to check args, it can't change
the arguments of the original dispatch.
I guess the proper way to do what I wanted would be to simply to set
parameter defaults/coercions generously in one multi and then re-dispatch.

Agree re helping out others with the same misunderstanding with a warning.
hopefully make this clear in docos soon :o)

On Wed, Oct 28, 2015 at 12:18 AM, jn...@jnthn.net via RT <
perl6-bugs-follo...@perl.org> wrote:

> On Wed Oct 21 06:34:47 2015, lloyd.fo...@gmail.com wrote:
> > 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.
> >
> I wouldn't expect it, nor defaults, to do so; the multis are still subs
> with their own signatures. Further, we rely on the ability to not have to
> really call an onlystar proto at all for optimization, and since all
> operators are multi-dispatch, that's important. Arguably, the use of
> certain features in an onlystar proto could add a note to the "potential
> difficulties", since it's very likely a thinko.
>
> /jnthn
>
>

Reply via email to