What's the conceptual difference (or relationship) between context and type
coercion? Is
$moose.prefix:<~>
the same as
$moose.coerce:<as>(Str)
for instance?
And forgive my brain, but how would you nicely define coercion in a class?
Like, could you spare an example?
Also, what's the point of making a whole grammatical category for "coerce"
that behaves like an infix operator?
Thanks in advance.
No difference.
: And forgive my brain, but how would you nicely define coercion in a class?
: Like, could you spare an example?
Currently something like:
multi submethod infix:<as> ($self: Str) {...}
multi submethod infix:<as> ($self: Int) {...}
or
multi sub infix:<as> (MyClass $self, Str) {...}
multi sub infix:<as> (MyClass $self, Int) {...}
: Also, what's the point of making a whole grammatical category for "coerce"
: that behaves like an infix operator?
In the current synopses there is no "coerce" grammatical category
any more. Everything is subsumed under infix:<as>, at least this week...
There's some discussion about whether it should simply be:
method as (Str) {...}
method as (Int) {...}
maybe with an "is deep" thrown in for good measure, but we haven't
quite got there yet.
Larry
Er, to have multiple of them in the same class, that would of course
have to be:
multi method as (Str) {...}
multi method as (Int) {...}
Generally, I love to travel. Specifically, I love the fact that
jet lag is a such a convenient excuse for stupidity.
Larry