On Thursday, December 11, 2003, at 10:04 AM, Larry Wall wrote:
Explicitly:

    $bar.does(Color)    # does $bar know how to be a Color?
    $bar.as(Color)      # always cast to Color

Implicitly boolean:

    $bar ~~ Color       # $bar.does(Color)
    ?$bar.Color         # $bar.does(Color)
    if $bar.Color       # if $bar.does(Color)

Implicitly non-boolean:

    +$bar.Color         # +$bar.as(Color)
    ~$bar.Color         # ~$bar.as(Color)
    $($bar.Color)       # $($bar.as(Color))
    @($bar.Color)       # @($bar.as(Color))


So C<as> would be for casting, not coercion, right?

Suppose you have a class Foo, such that:

  class Foo does (Bar, Baz) {
      ...
  }

... or however that looks. May I then presume that

$foo.Bar.zap # ($foo.as(Bar)).zap)

calls the method C<zap> of role C<Bar>, with $foo as the invocant?


MikeL




Reply via email to