Array versus hash isn't an issue if you ask me. The penalty you pay for constants is probably larger than those for a hash lookup. Constants are really subroutines, and subroutine calls use the stack.
The advantage of array-based objects, as far as I can tell, is reduced memory usage. You are only storing data and not hash-keys. They are faster, in theory, it would seem, but not in practice. If you used
Filter instead of
constant, then I might agree. A small compile-time penalty for a large run-time improvement. Another alternative, although a bit
bold, is to use pseudo-hashes.
Hash-based structures are fully extensible, and can be sub-classed easily. I don't think the same holds true for the array-based ones. How do you know where the parent left off, index wise? Do you have to keep track with another constant?
All of this is speculation, of course, until some testing is done to see if it is true.
One thing I would like to do is take something like
Autoload::Hash and extend it into a module which could fully realize the benefits of the array-based object (speed, memory) without requiring more code maintenance. Automatic code generation means referential integrity.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.