in reply to Address of anonymous hash

You should never use a memory-address as a “key.”   It is never wise to build code that is in any way dependent upon “an implementation side-effect,” even if that side-effect appears to be stable.   You will get burned ...

Replies are listed 'Best First'.
Re^2: Address of anonymous hash
by ikegami (Patriarch) on Feb 02, 2011 at 17:28 UTC

    You should never use a memory-address as a “key.”

    Have you heard of inside-out objects? At the base, they do exactly what just proclaimed shouldn't be done.

    { my %objs; sub new { my $obj = { ... }; my $key = 0+$obj; $data{$key} = $rec; return $key; } }

    (Blessing omitted for clarity.)

    I don't know to what side-effect you are referring. That numification of a reference returns its address? That's safe.

Re^2: Address of anonymous hash
by ikegami (Patriarch) on Feb 02, 2011 at 17:29 UTC

    You should never use a memory-address as a “key.”

    Have you heard of inside-out objects? At the base, they do exactly what just proclaimed shouldn't be done.

    { my %objs; sub new { my $obj = { ... }; my $key = 0+$obj; $data{$key} = $rec; return $key; } }

    (Blessing omitted for clarity.)

    I don't know to what side-effect you are referring. That numification of a reference returns its address? That's safe.

    A reply falls below the community's threshold of quality. You may see it by logging in.