develooper Front page | perl.perl5.porters | Postings from October 2001

Re: [PATCH] core-only patch for clamp/readonly hashes

Thread Previous | Thread Next
Rafael Garcia-Suarez
October 31, 2001 13:54
Re: [PATCH] core-only patch for clamp/readonly hashes
Message ID:
On 2001.10.31 19:08 Graham Barr wrote:
> On Wed, Oct 31, 2001 at 09:59:14AM -0800, Jeffrey Friedl wrote:
> > I think the analogy is also missing that with a restricted hash (or,
> > perhaps, "enumerated-key hash"), it is an error to try to access, other than
> > with exists(), a non-approved (non-enumerated) key.
> > 
> > If a hash's approved keys are: Verbose, Quiet and one tries to access
> > {Verbose}, you'll get its value if it has one, or undef if it doesn't. But
> > if one tries to use {Quite} (note misspelling), it is an error. This
> > functionality is orthoginal to any full or partial readonlyness of the hash
> > keys.
> So why make exists an exception to the rule ? Surly people can mistype
> the element name passed to exists just as easily.

That's what NI-S was saying : "exists $hash{baz}" fires an error on a
non-existing key. But in this case an API is needed to know what's the set
of allowed keys, or perhaps only to know whether some key is allowed. What
will this API do with regular hashes?

I'm a little confused by the distinction between 'existing keys' and
'allowed keys'. Please excuse this naive question from someone jumping
into this threads : can't those two notions be merged, for
simplicity? (In this case deleting a key from a restricted hash will be
always disallowed). In other words: what is this distinction useful for?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About