Re: References to hash elements?

[email protected] (Dan Sugalski)
Newsgroups perl.perl6.internals,perl.ponie.dev
Message-ID <a06010200bc21bd5ce29d@[10.0.1.2]>
At 1:32 PM -0800 1/6/04, Jeff Clites wrote:
>On Jan 6, 2004, at 9:25 AM, Leopold Toetsch wrote:
>
>>Arthur Bergman <[email protected]> wrote:
>>>Hi,
>>
>>>I am wondering how the references to hash elements are planned to be
>>>done? The call to set_ must somehow be delayed until the time is right.
>>
>>>$foo = \$hash{key};
>>
>>>$$foo = "bar";
>>
>>>$has{key} is now "bar"
>>
>>There was some discussion WRT that issue months ago. Currently the
>>implementation is wrong IMHO. When $hash{key} doesn't exist a new
>>PerlUndef is returned (which is fine) but it should be stored in the
>>hash too, so that assigning to $foo does The Rigth Thing.
>>(Parrot aggregates have reference semantics, so ...)
>
>This may have been discussed previously, but I would think that 
>reading a hash should never auto-vivify elements.

This is entirely a matter of opinion and data design -- both options 
are reasonable, and would depend entirely on the definitions imposed 
by the language (if they're core data elements) or the class author 
(if they're not).
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[email protected]                         have teddy bears and even
                                       teddy bears get drunk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.