On Tue, Aug 01, 2000 at 10:27:18PM +0100, Alan Burlison wrote:
> 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

Right, which is what very-strict would prevent, assigning values to $foo
that aren't constants or declared as integers; meaning, very-strict would
prevent you from assigning run-time-determined values to $foo.  You would
then need functions that return type-checked values (akin to C's atoi()).


> > 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. 

The overhead thing has been addressed in later emails in the thread; I heard
at one point that Topaz was very quick, or could be very quick, with tied
variables due to the usage of vtables and/or C++ constructs.

As for Perl's expressive power, I personally don't see a problem in
self-restricting your own coding practices to get some perceived gain.  I
intentionally use strict and -w, and don't use certain constructs, so as to
make my code more readable and a little cleaner (IMHO).  If there's no drop
in efficiency for the rest of us, I would think it'd be ok to allow those
who want type checking to have it, or at least some form of it.  It also
gets the rest of us faster tied variables, and the efficiency of declaring
an array to consist of all integers.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to