In
Advanced Perl Programming, Sriram Srinivasan has a very interesting idea for object-oriented storage. Instead of focusing on the object as the atom, he focuses on the class, using a series of package-global parallel arrays, each array being a given attribute. The "object" is now a blessed scalar reference containing the index within the parallel arrays.
The implementation he suggests in his book does NOT work. I worked on it and have an implementation that does, quite nicely. (I have to finish cleaning up the import function, but that's a matter of when I get around to it. I'll post it when I'm done.)
One thing to note is that different implementations are best for different things. The hash method is best when you have a class that will instantiate few objects, the objects are relatively static (don't get created and destroyed often), and have a relatively large number of attributes. The parallel array method is better for a class that will have a large number of objects, will create and destroy them on a regular basis, and has a small number of attributes. I've never worked with an array-ref type object, so I don't know much about them.
In case you're wondering, no - I haven't run it through Benchmark. I'll have to do that, soon.
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.