On Mon, Apr 03, 2006 at 07:23:28PM -0700, Joshua Choi wrote:
: Kudos to all on the Perl 6 mailing list,
: 
: What's the conceptual difference (or relationship) between context and type
: coercion? Is
:     $moose.prefix:<~>
: the same as
:     $moose.coerce:<as>(Str)
: for instance?

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

Reply via email to