On Sat, May 14, 2005 at 10:54:34AM +0800, Autrijus Tang wrote:
: On Fri, May 13, 2005 at 07:28:03PM -0700, Larry Wall wrote:
: > That's what .id is supposed to do, without the bogus numorstringification
: > semantics.  It should return something opaque that matches with ~~.
: Okay, implemented as such.
: What does unboxed values return for their "id", though?
:     3 =:= 3;      # always true?
:     3.id ~~ 3.id;   # ditto?

I think immutable values could work that way, especially if we want to
store only a single representation of each immutable string.  Basically
anything with an id can use that id as its hash key.  On the other
hand, we don't want to start hashing a boxed immutable value as some
different value just because it got transparently boxed up, so we have
to be careful about that.

And in particular, if hash keys are to work as in Perl 5, we're really
taking an immutable snapshot of the mutable string and using that for
the key.  In essence, whenever you modify a string, you're changing
its identity.


Reply via email to