[nem-en] Late Binding in Nemerle

Snaury snaury at gmail.com
Thu Jul 20 22:08:21 CEST 2006


It's fine for me. :)

However, with current implementation it seems one must avoid named
parameters for .NET classes (for ComObjects named parameters work fine
though [on MS.NET, never tested on Mono] and for MarshalByRefObjects I
just didn't test it). DefaultBinder in MS.NET has a horrible bug which
sometimes passes named parameters in wrong order, and Mono's
DefaultBinder doesn't currently support named parameters at all.

Consider example:

public class TestClass
  public Method(a : int, b : int, c : int = 3) : int
    printf("TestClass.Method(%d,%d,%d)\n", a, b, c)
    a + b + c

def t = TestClass()
def o = t : object
def n = late o.Method(c = 1, a = 2, b = 3) :> int
printf("Got result: %d\n", n)

On MS.NET:
TestClass.Method(3,1,2)
Got result: 6
On Mono:
TestClass.Method(1,2,3)
Got result: 6

Both are wrong of course (but I must say that MS.NET doesn't *always*
get order wrong, if there are less that 3 named parameters they will
always be correct, btw). Not that I want to scare you, but I just want
to mention it before you put it to nemerle codebase (even though these
are *not* my bugs, but bugs of underlying implementations). To fix
this on both platforms I'd need to implement my own (correct) binder,
which is a huge work, will impact performance, and I'm still weighing
whether I want to code all of this or just wait when both parties fix
their binders...

Anyway, you're welcome to include it. :) Just in case, because I don't
know what version you currently have, fresh version can be taked from
http://snaury.googlepages.com/Kitsu.Latebinding (old link just
redirects here, though)

On 7/20/06, Kamil Skalski <kamil.skalski at gmail.com> wrote:
> Well, I played a bit with the late binding macros and they work nice. :-)
> What do you thing about including them into Nemerle standard macros?
>
> For example under namespace Nemerle.Late;



More information about the devel-en mailing list