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

Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained

Thread Previous | Thread Next
From:
Charles Bailey
Date:
July 14, 2006 14:50
Subject:
Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained
Message ID:
b78749dd0607141449w31834524q592a03e103022274@mail.gmail.com
On 7/14/06, David Green <david.green@telus.net> wrote:
>
> On 7/13/06, Yuval Kogman wrote:
> >So, Larry assisted by Audrey explained the purpose of === vs eqv vs =:=.
> >It makes sense now, but I still feel that as far as ergonomics go
> >this is not perfect.
>
> I think I understand it... (my only quibble with the syntax is that
> === and eqv look like spin-offs of == and eq, but I don't know what
> to suggest instead (we're running short of combinations of = and : !))
>
> So there are three basic kinds of comparison: whether the variables
> are the same (different names, but naming the same thing); whether
> the values are the same (deep comparison, i.e. recursively all the
> way down in the case of nested containers); and in-between (shallow
> comparison, i.e. we compare the top-level values, but we don't work
> out *their* values too, etc., the way a deep comparison would).  If
> I've got it right, this is what =:=, eqv, and === give us,
> respectively.


It may well be that I'm misunderstanding here -- I've been away from Perl
development for too long and have a lot of catching up to do -- but I'm
uneasy about using the terms "shallow comparison" and "immutably equal" to
describe the same thing.  If the  "true meaning" of  $a === $b is that
$a.id eq $b.id, where .id is the value for a "simple" type, I think it'd be
least confusing to just call it a shallow comparison.  "Immutable equality"
sounds more like a promise of deep and lasting equality, not an assertion
that equality is skin deep.  I make a similar inference from the long sigil
-- it has more the flavor of "more equal" than "a special case of equal" (to
me, at least).  Just to muddy the waters further, I'd think -- off the cuff
-- that you might do well with expectations to say

  == and eq - shallow comparison of numeric and string values, specifically
(with other types being
                     free to specify what their numeric and string values
are -- caveat usor)
                     Matches existing expectations of these operators
  ===           - deeply equal (equivalent to the current eqv); alias for
"isreally" or "isdeeply"
                     Expectation based on extending the == metaphor
  eqv           - Different names for the same thing (what I think =:= means
now)
                     Expectation based on glossing as "equivalent" rather
than "equal value".
  =:=            - Defined identically, with no promise about contents (what
I think === means now).
                     Expectation based on the use of : to indicate
declaratory behavior

Just two cents from a Perl6 newbie.

-- 
Regards,
Charles Bailey
Lists: bailey _dot_ charles _at_ gmail _dot_ com
Other: bailey _at_ newman _dot_ upenn _dot_ edu

Thread Previous | 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