This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Equality of coerced functions

No replies
Lucas Satabin
Joined: 2010-02-23,
User offline. Last seen 2 years 3 weeks ago.

Hi everybody,

I recently had the problem that I wanted to check equality of two
functions which were the result of method coercion from the compiler. As
far as this process creates each time a new instance of anonymous
function, this equality check always failed. I used the solution
proposed on this mailing list
(http://old.nabble.com/-scala--Equality-for-defs-td23371756.html) by
defining the methods to be coerced as values of type function. It worked
but I then had problems: for example method overriding is not possible
anymore, and the use of methods defined in a third party library not
designed as needed is not directly possible.

I tried to change this, by coercing methods to "named" functions instead
of anonymous ones. I wrote a document explaining why and how and added
this feature to the compiler (directly in the compiler, and as plugin).
The resources can be found at
https://secure.n7mm.org/forge/gregnieh/wiki/ScalaNamedFunctions (I know
that the certificate is not trusted because signed by a small personal
CA, but there is no non SSL access to this forge. It is however safe to
accept the certificate for this site ;))

I would like to know if the proposed solution makes sense to you when
needing to check the function equality (typically when
registering/unregistering callback methods) and to discuss it with you.
I hope this subject is interesting enough!

Lucas

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland