HaloO,

Autrijus Tang wrote:
On Thu, Aug 11, 2005 at 08:02:00PM +1000, Stuart Cook wrote:
   my Foo ::x;
a) ::x (<=) ::Foo (i.e. any type assigned to x must be covariant wrt. Foo)
b) ::x is an object of type Foo, where Foo.does(Class)
c) Something else?


My current reading is a) -- but only if ::x stays implicitly
"is constant".  So your "assigned" above should read "bound".

Same reading here! ::x is declared as a subtype of Foo.

Note that the subtype relation is *not* identical to the
subset relation, though. E.g. Foo (=) (1,2,3) gives
Foo (<=) Int but Foo is not a subtype of Int if Int requires
e.g. closedness under ++. That is forall Int $x the constraint
$t = $x; $x++; $t + 1 == $x must hold. Foo $x = 3 violates
it because 4 is not in Foo. OTOH ++ might not be specialized
on Foo and thus only ++:(Int --> Int) is applied anyway. But
that implies that Foo $x = 3; $x++ warps $x to Int or weird
things like (4 of Int but 3 of Foo) or (4 of Int but 1 of Foo)
when Foo is considered cyclic.


Also, can I do crazy stuff like this?

   my $a = ::Foo;
   my ::$a $obj;  # analogous to @$x, where $x is an arrayref


Note that $a at compile time is unbound, so that automatically fails.
Now had you written this:

    my $a ::= ::Foo;
    my ::$a $obj;

Then I can see it working.

But wouldn't it be right away optimized to

   my ::Foo $obj;

Same if it comes from a dynamic scope:

   sub foo( ::Foo )
   {
      my $a ::= ::Foo;
      my ::$a $obj;

      return $obj;
   }
   say foo( Str );
   say foo( Int );
--
$TSa.greeting := "HaloO"; # mind the echo!

Reply via email to