aixtal has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I just found out that anonymous hashes do not have a stable address throughout program execution :
The above fragment of code prints out adresses that seem to run in a cycle of 3 :use Scalar::Util qw(refaddr); for (1 .. 10) { print refaddr { foo => 1 }, "\n"; }
4303377064 4303375648 4303377184 4303377064 4303375648 4303377184 4303377064 4303375648 4303377184 4303377064
I guess this is due to some compilation internals. But still, I found it puzzling. I was naively expecting an anonymous hash to be compiled once and for all at a given place.
I wonder if some monk has an insight on this ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Address of anonymous hash
by Corion (Patriarch) on Feb 02, 2011 at 07:47 UTC | |
|
Re: Address of anonymous hash
by davido (Cardinal) on Feb 02, 2011 at 08:11 UTC | |
by aixtal (Sexton) on Feb 02, 2011 at 17:20 UTC | |
|
Re: Address of anonymous hash
by ikegami (Patriarch) on Feb 02, 2011 at 17:35 UTC | |
|
Re: Address of anonymous hash
by locked_user sundialsvc4 (Abbot) on Feb 02, 2011 at 15:30 UTC | |
by ikegami (Patriarch) on Feb 02, 2011 at 17:28 UTC | |
by ikegami (Patriarch) on Feb 02, 2011 at 17:29 UTC | |
|