develooper Front page | perl.perl6.language | Postings from July 2006

Easy Str === Str question: what is a reference type

Thread Next
From:
Aaron Sherman
Date:
July 12, 2006 08:41
Subject:
Easy Str === Str question: what is a reference type
Message ID:
1152718832.28796.417.camel@pps
S03 says:

        Binary === tests type and value correspondence: for two value
        types, tests whether they are the same value (eg. 1 === 1); for
        two reference types, checks whether they have the same identity
        value. For reference types that do not define an identity, the
        reference itself is used (eg. it is not true that [1,2] ===
        [1,2], but it is true that @a === @a).

There's a problem here, from my point of view. I'll take it one
assumption at a time:

      * $whatever.as<Object>.id ~~ $whateverelse.as<Object>.id is true
        if and only if $whatever := $whateverelse at some point in the
        past, either explicitly, or through some sort of folding.
      * Str is a boxed type, and thus is a "reference type"
      * Thus, Str should be compared by .id and not by value, according
        to the above.

So, IMHO, either there's a mistake in S03; Str is a special case WRT
===; or I misunderstand "reference type" (which S03 never defines).

Clarification please?

Two things were mentioned on IRC about this:

      * Str might be compared by .id, but .id for Str is based on the
        contents of its underlying storage... this worries me because it
        means that Strs with radically different "meanings" would be ===
        because their encoding is different.
      * A reference type might only mean containers (though S03 seems to
        imply that objects are included to me).

Thanks, and sorry for all the lame questions! I'm just trying to make
sure that the docs I write aren't utterly, worthlessly wrong. :-/

-- 
Aaron Sherman <ajs@ajs.com>
Senior Systems Engineer and Toolsmith
"We had some good machines, but they don't work no more." -Shriekback



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About