HaloO,

Autrijus Tang wrote:
On Mon, Aug 01, 2005 at 03:16:50PM +0200, "TSa (Thomas Sandla�)" wrote:

  sub equitype ( ::a $x, a $y) { ... }


That's not a bad idea at all.  I rather like it.  I'd just still like an
explicit type-unifying parens around ::a, just so people won't say

I try to maintain the 'parens only group' point of view. But it
seems to be violated elsewhere, too.


    sub foo (::Int $x) { ... }

and accidentally rebind Int.

Why so shy? It would rebind foo::Int with respect to the inside
of &foo. Of course the funny effect is that for a call foo( "blahh" )
foo::Int means Str :)

I guess this is why $Larry wants a role wrapped around such type parameter
instanciators:

  role Foo[::Int] # hides *Int
  {
     sub foo (Int $x) { ... }
  }

and explicit instanciation

  use Foo[Int]; # or some such
  use Foo[Str];
  use Foo[Num];

But I don't know if he also wants to carry that on to the actual calls:

  Foo[Int]::foo(42);
  Foo[Str]::foo('42');
  Foo[Num]::foo(3.14);

OTOH, one has to use *::Int or *Int to surely get the standard Int,
anyway. And for getting guaranteed type locality inside &foo a

  sub foo( MY::Int $x ) {...}

might be needed, too. This nicely fits other pseudo namespaces:

  sub foo(      Int $x ) {...}  # whatever Int is in effect
                                # at compile time
  sub foo(    ::Int $x ) {...}  # deferred lookup to CHECK time
  sub foo(  MY::Int $x ) {...}  # dynamically from $x
  sub foo( foo::Int $x ) {...}  # same for all invocations? error?
  sub foo( OUR::Int $x ) {...}  # from package

How usefull OUTER::, CALLER::, etc. are I have no idea. Perhaps it's
a good idea to reserve single capital letter barewords for type params.
Or a twigil if we think of '::' beeing s sigil:

  sub foo( ::^a $x ) {...}

This saves one character compared to your (::a) which is the
same length as MY::a.
--
$TSa.greeting := "HaloO"; # mind the echo!

Reply via email to