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

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

Thread Previous | Thread Next
From:
David Green
Date:
August 15, 2006 13:32
Subject:
Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained
Message ID:
a06230930c107ba7fa1e6@[172.27.1.7]
On 8/14/06, Smylers wrote:
>David Green writes:
>Thanks for that.  In summary, if I've understood you correctly, it's that:
>
>   =:=  two aliases to the same actual variable
>   ===  one variable contains a copy of the other's actual contents
>   eqv  both contain contents which represent the same thing but may have
>        come from different sources
>
>And that being true at one level implies being true for the above 
>levels.  Yes?

Right. (Where the ordering for "above" means =:= implies ===, and === 
implies eqv, but not in the other direction, of course.)

>  > ===
>>  Example: Suppose I have some employee objects, and I employ two John
>>  Smiths.  They have the same name, work in the same department, and by
>>  stunning coincidence everything my class knows about them just
>>  happens to be the same.
>
>Except that they wouldn't.  Because each one would have a separate 
>payroll number, or some artificial thing invented just for the sake 
>of being different.  So this example doesn't sound plausible to me.

Well, I didn't say it was a *good* payroll system!  OK, it's a silly 
contrived example; maybe my objects should have represented the 
reticulated flanges I have in stock, since one piece of inventory is 
the same as any other.  Except I wouldn't really create an object for 
each one, I'd just have a single group-object that contained a 
$num_available counter....
(Anyone cleverer than I should feel free to jump in with a better example.)

>So I now understand what this operator does.  But I'm still 
>struggling to fathom where I would ever have a use for it.

Maybe you wouldn't -- eqv is what most of us will use most of the 
time, I expect (being the ordinary everyday parallel to == and eq). 
But since it is possible to use variables both by value and by 
reference, there still needs to be a way to work with and compare 
both of them when you want to do fancy advanced stuff.


-David

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