On Thursday, 22. October 2009 18:31:16 I wrote:
> The invocant slot of the role signature is sort of implied in the spec
> already! I also like this because a type in Perl 6 is then always
> written as SomeRole[SomeClass:]. Classes without explicit roles are
> Any[SomeClass:] and untyped is Any[Object:]. Note that a class C doing
> multiple roles spawns several types R1[C:], R2[C:], etc and the class
> name is a short form of their juxtaposition.

Here is an improvement of the concept that also allows to settle the
Dogwood case in the Dogwood class. The change is that plain Foo does
not mean Foo[Object:] but denotes the F-bound fixpoint type Foo[Foo:].
A class Bar doing Foo still creates the type Foo[Bar:] but also enters
the subclass relation between Bar and Foo so that Foo[Bar:] <: Foo[Foo:]
makes Bar instances applicable where Foo is required.

The class Dogwood however might be written as

   class Dogwood does Dog[Dogwood:] does Wood[Dogwood:]
       method Dog {...}
       method Wood {...}
       method bark {...}

where the explicit invocant type prevents the creation of the
subclass relations between Dogwood and Dog and Wood. So in an
environment which requests plain Dog a Dogwood instance is only
applicable after the call of the coercion routine which could
setup things so that Dog::bark is dispatched to. Environments
that want Dogwood::bark need to explicitly coerce Dogwood instances
to Dog[Dogwood:] which actually is a no-op. But then other non-Dogwood
Dog doers are excluded unless they have a Dogwood coercion routine.
Or they use the Dogwood class directly.

Regards, TSa.
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to