Re: Context and coercion

2006-04-03 Thread Larry Wall
On Mon, Apr 03, 2006 at 08:24:51PM -0700, Larry Wall wrote:
: 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.

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


Re: Context and coercion

2006-04-03 Thread Larry Wall
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:(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: ($self: Str) {...}
multi submethod infix: ($self: Int) {...}

or

multi sub infix: (MyClass $self, Str) {...}
multi sub infix: (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:, 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