Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Preventing autovivification

by BrowserUk (Patriarch)
on Feb 16, 2010 at 05:51 UTC ( [id://823410]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Preventing autovivification
in thread Preventing autovivification

In addition to this, you need to isolate the object (inside out) from the implementation (hash).

Sorry, but I think you are compounding two different goals and coming up with a lemon.

The original goals of IOOs were:

  • Proper encapsulation
  • Compile time checking of attribute use.
  • A technique not a module.
  • Don't depend on the implementation of the superclass.
  • Don't force a particular implementation on subclasses.
  • Simplicity.

What you are suggesting is that the internal data implementation should be encapsulated (isolated) from the internal code. This was never a (stated) design goal, but can be achieved by the religious use of accessors, internally.

In short, there is no way to stop an attribute from being added to a hash data structure. Auto-vivification is just part of the behavior of hashes.

Actually, I think Hash::Util was specifically designed to address this.


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found