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

Re: ~ and + vs. generic eq

Thread Previous | Thread Next
From:
Damian Conway
Date:
August 24, 2005 00:00
Subject:
Re: ~ and + vs. generic eq
Message ID:
430C1A5A.6000802@conway.org
Larry wrote:

> Or we could have a different operator that coerces like == and eq, only
> via .snap:
> 
>     if [1,2,3] equals [1,2,3]     { say "true" } else { say "false" }
> 
> (Actual name negotiable, of course).  The advantage of the latter approach
> is that you can say
> 
>     @foo >>equals<< @bar
> 
> and the .snaps are automatically distributed.  Otherwise you'd have to say
> 
>     @foo<<.snap >>eqv<< @bar<<.snap
> 
> which is a pain.  On top of which, equals doesn't actually have to
> implemented in terms of .snap--it could just compare the current
> values of the mutable objects directly.  (Just as =:= doesn't have
> to be implemented in terms of .id.)

Just a meta-point...one thing we really do need to be careful of is not ending 
up with 17 different "equality" operators (like certain languages I shall 
refrain from naming). So far we're contemplating:

	=:=
	~~
	==
	eq
	eqv
	equals

Do we really need even that many???

Damian


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