As documented in RFC89, the format of declaration is

        my $varname;
        my (var-list);
        my cast-type $varname;
        my cast-type (var-list);

        my $varname:constraint;
        my (var-list):constraint;
        my cast-type $varname:constraint;
        my cast-type (var-list):constraint;

        my $varname:(constraint-list);
        my (var-list):(constraint-list);
        my cast-type $varname:(constraint-list);
        my cast-type (var-list):(constraint-list);

So it agrees with the form
my int @sparse_array : sparse(0,0.99) = ((0) x 50000 , 1);


In Perl, it is very usual for modules to accept the scalar form and also
allow the the vector form. The vector form would be within round brackets ()
for arrays and brace bracketts for hashes.

In RFC89, this would allow more than one constraint. So one could code
my int x: whatever;
or
my int x:(whatever);
or
my whatever x:int;
or
my @constr=(whatever,int);
my x:@constr;
or
my @constr=(whatever);
my x:@constr;
push @constr, int; #Controllability


In response to James' -

> my int @sparse_array : sparse(0,0.99) = ((0) x 50000 , 1);
Ahh, it does.  See the attributes module.  You're example would have to be
somthing like "my int @sparse_array : sparse((0,0.99) = ((0) x 50_000, 1));"
as the attribute's arguments have to be in a parenthesized phrase.




Reply via email to