Method Pointers
Miles Sabin
miles at milessabin.com
Mon Feb 27 00:36:08 PST 2012
On Mon, Feb 27, 2012 at 7:54 AM, Conrad Winchester <conrad at dz015.com> wrote:
> Have to agree with Vitaly here, I think the SAM implementation should allow for equality or a different approach taken.
>
> I think that this lack of equality is a shame, because
>
> 1) other languages have dealt with this without this level of confusion.
> 2) it will cause the community to be plagued with exactly the same question over and over again - it feels like an incomplete implementation of method pointers.
> 3) as was stated in the other thread it makes the use of method pointers as listeners almost completely useless.
FYI, a quick illustration of the current semantics for the Scala equivalent,
scala> class Foo { def foo(i : Int) = i }
defined class Foo
scala> val foo = new Foo
foo: Foo = Foo at 49ab0137
scala> val f1 = foo.foo _
f1: Int => Int = <function1>
scala> val f2 = foo.foo _
f2: Int => Int = <function1>
scala> f1 eq f2
res0: Boolean = false
scala> f1 == f2
res1: Boolean = false
scala> f1.equals(f2)
res2: Boolean = false
I don't recall any serious objections to this behaviour. In practice
if you use these things in a functional style the lack of identity or
equality is a complete non-issue.
Cheers,
Miles
--
Miles Sabin
tel: +44 7813 944 528
gtalk: miles at milessabin.com
skype: milessabin
g+: http://www.milessabin.com
http://twitter.com/milessabin
http://www.chuusai.com/
More information about the lambda-dev
mailing list