in reply to Re^6: How to allocate a struct?
in thread How to allocate a struct?

Maybe there indeed exists a "Perl-ish" way to avoid this...

The immediate, 'obvious' solution to your problem is a hash. (Or perhaps a tree of hashes; its hard to discern from your brief description.)

C-structs are simple aggregates of named fields; with the addition that one or more of those named fields can contain pointers to other structs.

This can be exactly mirrored using hashes; that possibly contain named references to other hashes.

The down side of this is that hashes are relatively memory hungry and slow when compared to C-style structs; but they smaller and far, far faster than any OO-wrapper to provide the same facility.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.