Identity vs equality (was Re: [Newbies] Assignment)
by goran other posts by this author
Aug 10 2007 1:32AM messages near this date
Re: find original change set
|
Re: Identity vs equality (was Re: [Newbies] Assignment)
Hi!
(cc to squeak-dev)
> > All the character is unique so is better (faster) to use #==.
>
> This is not true for Characters whose code is bigger than 256.
>
> To me, the identity comparison is more or less in the "meta" level
> or touching implementation details. Unless you eally need to check
> the "identity" for a good reason, you should always use #= for
> comparison, I think. (Some performance critical potion of code could
> be exempted... but it should still be limited very carefully.)
>
> -- Yoshiki
Just wanted to mention that this came up on IRC the other day and IMHO one
can generally go by this rule - use #= for equality and only use #== if
you actually *intend* to check for identity. It is slightly poor style to
use #== just to gain a bit of speed, when you in fact *mean* equality.
If we generalise the rule is - program by intention as much as possible
and instead focus on Compiler and friends for speed tricks. :)
It might be interesting to hear what Bryce thinks about this - could for
example Exupery get "tricked" by using #== when you actually mean #= and
actually end up making slower code than if the developer had used #=?
In this particular case it may very well be so that identity checks are
faster than any conceivable equality check - but who knows. :)
regards, Göran
PS. Sure, I have also broken this rule, no doubt about that. ;)
Thread:
goran
Nicolas Cellier
Alexander
Nicolas Cellier
Nicolas Cellier
Igor Stasenko
Nicolas Cellier
Klaus D. Witzel
goran
Andreas Raab
goran
Craig Latta
Andrew Tween
Stephane Ducasse
Andreas Raab
Stephane Ducasse
Blake
Stephane Ducasse
Andres Valloud
Jon Hylands
Stephane Ducasse
Andreas Raab
Stephane Ducasse
Philippe Marschall
Keith Hodges
Stephane Ducasse
Andreas Raab
Alexander
Blake
Andres Valloud
Lukas Renggli
Andrew Tween
Yoshiki Ohshima
Andrew Tween
Philippe Marschall
Andrew Tween
Lukas Renggli
Philippe Marschall
|