On Jan 6, 2004, at 9:05 AM, Simon Cozens wrote:

Arthur Bergman:
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.

I would have thought that a hash element would itself be a PMC rather than an immediate value, so a reference to that should be treated just like any other reference to a PMC.

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". Consider:


# example 1
$a = "foo";
$b = \$a;

# example 2
$hash{bar} = "foo";
$a = $hash{bar};
$b = \$a;

# example 3
$hash{bar} = "foo";
$b = \$hash{bar};

Examples 1 and 2 should be identical in terms of what $a and $b contain; in particular, modifying $b doesn't affect the hash in example 2. In example 3, $b contains something different (a hash element reference), and assigning to it does change the hash. (That is, assuming we have hash element references of this sort.) That is to say, reference-to-hash-element-for-key(bar) is not the same as reference-to(hash-element-for-key(bar)).

JEff



Reply via email to