Re: References to hash elements?

[email protected] (Simon Cozens)
Newsgroups perl.perl6.internals,perl.ponie.dev
Message-ID <[email protected]>
Jeff Clites:
> But there's a semantic difference between a "reference to a hash 
> element" and a "reference to something which happens to have come out 
> of a hash".

True, but irrelevant. :)

> $a = $hash{bar};

Here you used the copy constructor before taking the reference. It might look
like an assignment operator, but it isn't. You're better off thinking that
assignment doesn't exist. It's a copy constructor. It makes the PMC referred
to by $a a copy of the PMC in $hash{bar}. Their values may be "equal" but
they're two different PMCs.

> $b = \$hash{bar};

Here you didn't make a copy before taking the reference. No copy, only one
PMC. It all works.

-- 
BITTERNESS:
    Never be Afraid to Share Your Dreams with the World,
    Because there's Nothing the World Loves More Than The Taste of
    Really Sweet Dreams                              http://www.despair.com
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.