Michael Fowler wrote:
> use typing qw(very-strict);
>
> my integer $foo : very-strict = 4;
>
> Which would enforce that you can only assign integer constants to $foo
> (which are seen at compile-time), or other similarly declared integers (or
> possibly promoted floats, chars, etc. if you wanted to get C-like). This,
> then, could allow you to do checking at compile-time.
my integer $foo : very-strict = 4;
my $val = <STDIN>;
$integer = $val; # This can only be checked at run-time
> So, strong typing is doable, and not burdensome to those who don't want to
> use it (which includes me). You can even get some efficiency gains from it.
IMHO a slightly-strongly-typed language is like a slightly-pregnant
woman - an impossibility.
> This is not necessarily an endorsement for type checking, but I see more
> than a few people asking for it, and if it can be done without severely
> impacting those who don't want it, there's little reason to deny them (that
> I can see).
No, I disagree. Perl gains a lot of its expressive power from being lax
about typing. I suspect it will also impose an unacceptable overhed for
the vast majority who don't want it - at the very least every variable
access will have to check an 'are you typed' flag.
--
Alan Burlison