Method Pointers

Neal Gafter neal at
Fri Mar 23 13:02:08 PDT 2012

On Thu, Mar 22, 2012 at 11:15 PM, Ted Neward <ted at> wrote:

> That would be tricky; under the covers, a Delegate is a wrapper around a
> metadata token (the primary key in to the relational table in which all
> .NET
> metadata is stored, in contrast to the tree structure of .class files), so
> it's easy to compare the metadata tokens. Lacking any sort of primary key
> in
> the .class files, the JVM is back to the problems that Brian mentioned
> earlier.

I think we're imagining that .NET gives us more than it actually does.  The
fact that two .NET delegate objects have distinct metadata tokens gives you
no information as to whether or not they represent the same underlying
lambda expression.  So .NET isn't in much better shape.  Specifically, the
following snippet of C# code prints "False":

        System.Action a1 = () => { };
        System.Action a2 = () => { };
        System.Console.WriteLine(a1.Method == a2.Method);

More information about the lambda-dev mailing list