Re: References to hash elements?

[email protected] (Jeff Clites)
Newsgroups perl.perl6.internals,perl.ponie.dev
Message-ID <[email protected]>
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. (That would be contrary to 
the Perl5 semantics, at least.) You may need to return a special 
reference-style PMC which knows how to get back to the original hash if 
you assign to it, but the hash itself shouldn't grow entries.

JEff
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.