develooper Front page | perl.perl6.language | Postings from May 2005

Type system questions.

Thread Next
From:
Autrijus Tang
Date:
May 3, 2005 02:06
Subject:
Type system questions.
Message ID:
20050503090615.GA39096@aut.dyndns.org
With the recent discussion on type sigils, and the fact that Pugs
is moving toward the OO core, I'd like to inquire how the following
statements evaluate (or not):

    # Compile time type arithmetic?
    ::Dual ::= ::Str | ::Num;
    $*Dual ::= ::Str | ::Num;

    # Run time type arithmetic?
    my ::dual := ::Str | ::Num;

    # Type Instantiation?
    sub apply (&fun<::a> returns ::b, ::a $arg) returns ::b {
	&fun($arg);
    }

    # Does Role live in the same namespace as Types/Classes/Modules/Packages?
    my ::role = role { ... };

    # Can class take type parameters like Roles cna?
    class Pet[Type $petfood] {
	method feed (::($petfood) $food) {...}
    }

    # Single colon as tuple composer?
    my $Triple		::= :(Bool, Int, Str);
    my $TripleTuple	::= :($Triple, $Triple);
    my &pair_with_int	::= -> Type ::t { :(::t, Int) };

Thanks,
/Autrijus/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About