Next | Making Programs Faster | 90 |
This idea was developed over the next few years
Big problem: This cannot be translated at compile time
$self->{$key}
Solution: $self would be an arrayref that pretended to be a hashref
It would carry around a hash that mapped keys to values:
[ { NAME => 1, TYPE => 2, size => 3, ... }, "Fenchurch", "Octopus", "Small", 3, undef, ... ]
You were now allowed to use an arrayref as if it were a hashref
This was formerly an error:
$array_ref->{$key}
Now it is an abbreviation for this:
$array_ref->[$array_ref->[0]->{$key}]
Note that this is somewhat slower than $hash_ref->{$key} would have been
Next | Copyright © 2003 M. J. Dominus |