in reply to best structure for classes?

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.