Next | Making Programs Faster | 89 |
For 5.005, someone had an interesting idea:
Suppose an object was declared from a certain class, like this:
my Critter $self;
Suppose Critter objects are based on arrays instead of hashes
And suppose Critter.pm declared its fields at compile time, like this:
package Critter; use fields qw(NAME TYPE size hearts likes_cookies ... pelagic tentacles is_tasty ... );
Then when Perl saw $self->{TYPE} it could pretend you wrote $self->[2]
You would get all the benefits of both!
Next | Copyright © 2003 M. J. Dominus |