Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060710]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-02-25 17:58 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (314 votes). Check out past polls.