2 ms·
That's a horrible hack indeed :) Perl 6 does have 'gradual typing' though. You can define a variant: my $foo; or a typed variable: my Int $foo; or a su
by rjh29 15y ago
That's a horrible hack indeed :)
Perl 6 does have 'gradual typing' though. You can define a variant:
my $foo;
or a typed variable:
my Int $foo;
or a subtype with arbitrary restrictions
subset OneToTen of Int where { 1 <= $^n <= 10 };
my OneToTen $foo;
Or... (http://rosettacode.org/wiki/Define_a_primitive_data_type#Perl_6 http://rosettacode.org/wiki/Define_a_primitive_data_type#Per...)
subset Prime of Int where { $^n > 1 and $^n %% none 2 .. sqrt $^n };
Perl 6 scares me.