Larry Wall wrote:
> Anyway, this all implies that use of a role as a method name defaults to
> returning whether the type in question matches the subtype. That is,
> when you say:
>
> $foo.true
> $bar.red
[...]
> $bar.red
[...]
> $baz.Byte
>
> it's asking whether the Int property fulfills the Byte constraint, but
> that's getting kind of strange.
If the roles are first class objects then their traits are defined
as methods, right?
Boolean.true($foo)
Color.red($bar)
Int.byte($baz)
Then assuming that certain objects "inherit" certain roles, you could
use something like the Perl 5 $self->SUPER::new() syntax. Only it would
look more like this:
$foo->Boolean.true
$bar->Color.red
$baz->Int.byte
> Another implication is that, if properties are subtypes, we can't use
> the same name as a cast method. Since
>
> $baz.Byte
>
> only returns true or false, we'd need something like (yuck)
>
> $baz.asByte
[...or...]
> $baz.as(Byte)
Or:
$baz->Byte
That would make something like this:
$foo->Color.red
the same kind of thing as:
$foo.as(Color).red
A