in reply to my TYPE EXPR ?
Declaring data types like "integer" might help with run time checking or code optimization...
The check is currently just a simple bit check. To get any benefit, you would have to eliminate the check completely by moving it to compile-time.
Let's look at $x+$y. (Looking at ops with a variable number of arguments would just complicate things.) It compiles into three ops:
1 padsv[$x] -> 2 2 padsv[$y] -> 3 3 add -> 4
There's nothing to affect! Right now, it would be of no benefit.
Let's look at what it would take to benefit from it. Let's suppose some of the code in "add" was taken out and turned into ops. $x+$y would then compile into the following code:
1 padsv[$x] -> 2 2 padsv[$y] -> 3 3 add_if_overloaded -> 11 if overloaded, 4 otherwise 4 swap_stack[0,1] -> 5 5 get_magic -> 6 6 numify -> 7 7 swap_stack[0,1] -> 8 8 get_magic -> 9 9 numify -> 10 10 add_prenumified -> 11
If both $x and $y are known to be numbers, the optimiser could turn the above into the following:
1 padsv[$x] -> 2 2 padsv[$y] -> 10 10 add_prenumified -> 11
But changing Perl to produce the above would require changing just about every opcode. And then there's the optimiser additions on top of that. That's a crazy amount of work.
What would be the result of that work?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: my TYPE EXPR ?
by LanX (Saint) on Apr 21, 2010 at 10:03 UTC | |
by ikegami (Patriarch) on Apr 21, 2010 at 15:28 UTC | |
by LanX (Saint) on Apr 23, 2010 at 09:57 UTC | |
by kennethk (Abbot) on Apr 21, 2010 at 14:13 UTC | |
by LanX (Saint) on Apr 21, 2010 at 14:22 UTC |