Front page | perl.perl6.language |
Postings from May 2008
Re: my TypeName $x;
Thread Previous
|
Thread Next
From:
TSa
Date:
May 9, 2008 05:24
Subject:
Re: my TypeName $x;
HaloO,
I wrote:
> class C does A does B {...} # enters C into WHAT space
>
> my $y = C.new; # $y.WHAT =:= C
>
> my $b <: B; # automatically re-typing container
> my $a <: A; # means e.g. my A $a is autotype
>
> $b = $y; # now $y.WHAT =:= B
> $a = $y; # now $y.WHAT =:= (A&B)
>
> This last assignment has to enter the meet type (A&B) into the
> type lattice because simply re-typing a B to an A is not possible
> unless A <: B holds. This needs to be declared explicitly somewhere.
> The declaration of class C doesn't do that, of course. So programs
> not using <: don't incur the type calculation overhead.
I left out the fact that after the declaration of C as
above there are then the four types C, A, B, and A&B in
WHAT space. They form the following lattice with the left
of <: going downwards.
A B
\ /
A&B
|
C
This type A&B there means everything that makes the closure
{ .does: A && .does: B} return True. With a junction this
can of course be written {.does: A&B}. The lattice is calculated
lazily as described in my previous mail.
The thing I want to add is that all classes that inherit from C
without adding additional roles are incomparable to C as far
as WHAT is concerned but all of them will eventually end up as
subtypes of A&B in their WHAT if containers and the dispatcher
use automatic type re-assignment.
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
Thread Previous
|
Thread Next