Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Is this ancient perl or just a cargo cult?

by BrowserUk (Pope)
on Nov 01, 2013 at 05:20 UTC ( #1060710=note: print w/ replies, xml ) Need Help??


in reply to Is this ancient perl or just a cargo cult?

To me, this looks like a dodgy cargo cult way of doing an ordered hash.

It is neither dogdy; nor cargo-cult; nor do they pre-date hashes. Both became available at exactly the same time with the advent of blessed references circa. 5.001.

The code is using a blessed array rather than a blessed hash as the basis of its objects. This is more compact and faster than the "normal" blessed hashes.

The constants give programmer-friendly names to the fields; whilst still allowing the field lookups to be optimally efficient.

For completeness, field lookup with a hash still requires an array lookup; but first the key (field name) has to be translated into an index number. And then, if you happen to be unlucky, there might need to be a linear search as well.

blessed arrays with named constant field indexes are a less used, but perfectly valid, highly functional and more efficient way of implementing objects in Perl.


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.


Comment on Re: Is this ancient perl or just a cargo cult?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060710]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-16 01:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (155 votes), past polls