On Tue, May 03, 2005 at 05:32:44AM -0700, Larry Wall wrote:
> :     # Type Instantiation?
> :     sub apply (&fun<::a> returns ::b, ::a $arg) returns ::b {
> :     &fun($arg);
> :     }
> 
> The first parameter would be &fun:(::a) these days, but yes.
> (Stylistically, I'd leave the & off the call.)

So, the "returns" trait is not part of a function's long name, but
it can still be matched against (and instantiated)?

Hrm, is it specific to the "returns" trait, or we can match against 
any traits at all?

    sub foo ($thingy does Pet[::food]) { ... }

Also, S12 talks about "is context":

    method wag ([EMAIL PROTECTED] is context(Lazy)) { $:tail.wag([EMAIL 
PROTECTED]) }

What is the type of "Lazy" here?  Also, is "context" a role or a class?
If it is a class, how does it parameterize over "Lazy" ?

> :     # Single colon as tuple composer?
> :     my $Triple              ::= :(Bool, Int, Str);
> :     my $TripleTuple ::= :($Triple, $Triple);
> :     my &pair_with_int       ::= -> Type ::t { :(::t, Int) };
> 
> I think of it as the signature composer.  Does Haskell call them
> tuples?  That word tends to mean any immutable list in other circles,
> though I suppose :(4, 2, "foo") could be construed as a type whose
> values are constrained to single values.

Err, sorry, I meant "tuple type composer".  In haskell:

    -- Value --           -- Type --
    (True, 1, "Hello") :: (Bool, Int, Str)

This was because I couldn't think of other operators other than ","
to operate on types inside :().  Come to think of it, there are lots
of other things possible:

    my $SomeType ::= :((rand > 0.5) ?? Bool :: Int);

Also, is it correct that (4, 2) can be typed as both a :(Eager) list and a
:(Any, Any) tuple?  Is it generally the case that we can freely typecast
unbounded list of values from (and to) bounded ones?

> But it makes :(int $x) terribly ambiguous if it's an evaluative
> context.  (Which is why we wanted :() in the first place, to avoid
> such evaluation.)

Evaluative context?

However, I'm a bit confused now.  Does a :(...) expression stand for a
type, a variable binding, or both?

    :($x)       # variable binding or deref $x into a type?
    :(Int)      # a type?
    :(Int $x)   # bind a type into $x?

If all three are allowed, then :($x) itself is ambiguous...  What would
these mean, then?

    :(:(Int $x) | :(Str $y));
    :((Int $x) | (Str $y));

Thanks,
/Autrijus/

Attachment: pgpbnRd3WYF4X.pgp
Description: PGP signature

Reply via email to