At 03:37 PM 9/17/00 -0700, I wrote:
><Brainstorming> How about an attribute for hashes:
>
> my %foo : fixed;
>
>And now new keys cannot be inserted into the hash just by assigning to
>their values. As to how you could put them there... well the ideas that
>come to mind are [snipped]
></Brainstorming>
Spurred on by the peanut gallery, I attempted to write an RFC for this, but
it is foundering. Here's why: the most common case of hashes whose keys
one would want to fix are anonymous, when they're used as column names in a
database hash. For instance:
$employee{$empno}{SAlARY} -= 10_000; # IPO failure
$employee{$empno}{FAX} = '888-555-1212';
First one got the wrong key when my finger slipped on the shift key, second
one got it when I misremembered FAX instead of FACSIMILE. But in neither
case does Perl point this out. (Yes, I could use objects instead, but
that's hardly the point.)
I have been unable to come up with a lightweight syntax for saying that the
second-level hash keys should be fixed. I supplicate the gods of new
syntax for any succor they may render in my hour of need.
--
Peter Scott
Pacific Systems Design Technologies