Gregory S Hayes wrote:
>
> Types just seem so very un-perl. There is much to be said for the
> universal scalar vairable. I'm not sure I fully understand just why we
> NEED types in the language.
> So what are the benifits of types?
Note: I am *not* claiming to be pro-types.
However, in cases such as this they might make more sense. Otherwise, I
could potentially see tons of pragmas cascading throughout code to try
and satisfy what are really variable-specific concerns.
Types do have certain advantages that should not be overlooked
regardless of one's religious views on the matter:
1. Storage optimizations
2. Tighter code-checking for crucial applications
3. Mathematical operation optimizations
I know there are others, but those are always the ones I remember off
the top of my head.
Anyways, I'm not for or against this RFC per se, but when we start
getting into complex optimizations, variable promotion, storage
concerns, and so on, there might be other approaches that are more
suitable. You won't be able to get all the "benefits" of true types
through a pragma, which is sort of like a hand grenade in that it's
block-specific, and not variable-specific.
A more fluid approach is to tag a variable that can then be followed
throughout the code by Perl. Less for you to worry about with pragmas,
and better optimizations potentially as well.
This typing wouldn't be mandatory (I haven't heard anyone suggest that),
but rather available if you wanted it:
my $x = 5.3;
my int $y = 10; # ooo! can optimize
The thinking I've heard is that you could still do anything you wanted
with $y (even assigning strings and floats to it) unless you have Nat's
proposed "strict types" on:
use strict 'types';
my int $z = 5.3; # nope! later...
Basically, default "types" in Perl would really be more like "hints"
that could save some valuable time and storage, without causing Perl to
be un-fun.
-Nate