At 09:25 PM 8/1/00 +0000, Nick Ing-Simmons wrote:
>Alan Burlison <[EMAIL PROTECTED]> writes:
> >
> >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.
>
>Cross posted to internals ('cos it is...)
>
>We should consider using "vtables" to avoid the cost of the conditional
>branches (and running out of flag bits).
Works for me. Anyone care to flesh this out a bit? (Take pity on a guy
who's not had C++ inflicted upon him... :)
>Thus this function would call variables "type check" "method" -
>which for normal case would be pointer to blue-white-hot "NoOp" function
>which is near always in-cache, for a typed var it could be a slow
>as you wanted...
I was thinking that, since the compiler has most of the information, a
"type check" opcode could be used, and inserted only where needed. If, for
example, you had:
my ($foo, $bar);
my ($here, $there) : Place;
$foo = $bar;
$here = $there;
You'd only need to typecheck the assignment to $here. Granted assignments
through references would need to check unconditionally, and a typecheck's
in order if you're not sure of the types (say, by directly referencing @_
elements), but the optimizer could certainly toss a lot of checks.
Strong typing could also get us a win other places. If, for example, we said:
my @foo : integer : strict;
meant that @foo *only* has integers in it, we don't need to store full SVs
in it, and use an integer array only.
If strict's off I don't see any reason to forbid bad assignments of 'known'
types--if someone, using the above example, did a "$foo[2] = 'bar'" I don't
see any reason not to make $foo[2] have a value of 0. (With a warning
emitted by -w, of course)
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk