Equality of lambdas
Alex Blewitt
alex.blewitt at gmail.com
Mon Jan 4 02:13:05 PST 2010
On 3 Jan 2010, at 23:04, Howard Lovatt <howard.lovatt at iee.org> wrote:
> Zdenek,
>
> For comparing lambdas
> you need to use equals not ==.
My experience in lambdas from other languages is that there's little
point in supporting equality of lambdas other than identity. In the
general case it's impossible to know whether two code segments will
produce the same result - so comparing non-identical lambdas is
somewhat futile. Even if you have a non-capturing lambda instance
(like the identity function) then even if two are equal, what benefit
does that give?Comparing lambdas of other types is unlikely to give
the same result - and a good compiler should be able to optimise two
lambdas in different locations but with the same AST to the same
instance (preferably static if non-capturing). So that may introduce a
level of visibillity into the workings of the compiler that may
inhibit future optimisations.
On the other side of the coin - what is it that equality is supposed
to assist with?
Sent from my (new) iPhone
>
More information about the lambda-dev
mailing list