[nem-en] Late Binding in Nemerle

Kamil Skalski kamil.skalski at gmail.com
Tue Jul 4 18:42:38 CEST 2006


This is a very nice addition. :)

The impossibility to use AddImplementedInteface at this stage is
indeed a limitation of the GlobalEnv.Define function - it should
accept the second parameter to disable "fixup" of class.
It is currently done in method TypeBuilder.DefineNestedType, which is
unfortunately also not publicly available.

Also, the quotation mechanism do not allow the more general syntax at
the moment:

def ifaces = [<[ IFoo ]>, <[ IBar ]>,  parm1, parm2];
ctx.Env.Define ( <[ decl:
  class A : ..$ifaces {
  }
]>);

which would be consistent with other places where we accept ..$x

I will fix both issues, so our API and quotation syntax is more flexible.


2006/7/4, Arthur Peters <amp at singingwizard.org>:
> I hope this isn't a duplicate, but the first time I sent this it didn't appear to go through.
> ---
> Hi there,
>
> I've implemented this idea. The implementation seems to work. I based it
> on the helper classes that Snaury created for the late(x) macro.
>
> Notable features/misfeatures are:
> * It does not verify that the object passed to it fully implements the
> interface and if a method is not implemented it you will get a
> System.MissingFieldException at runtime when you call a function that is
> not implemented. This could be very useful in some cases, but it results
> in odd exceptions that could occur deep in libraries.
> * It puts the proxy class that implements the interface in the global
> namespace (I think) and will reuse it based on its name if you use the
> macro again with the same interface.
>
> Bugs:
> * It does not support indexers, but I'm sure they could be added.
> * It only supports implementing 1 interface. I don't think this is a
> major problem, but see below.
> * I don't know the nemerle internals very well, so the code is ugly and
> I suspect incorrect in places.
>
> I tried to allow it to implement more than 1 interface, but I could not
> figure out how to add the interfaces after the initial Define call.
> TypeBuilder.AddImplementedInterface fails because the compiler has
> passed the phase required by it. Any help would be appreciated.
>
> I hope somebody can use this code.
> -Arthur
>
> On Mon, 2006-07-03 at 03:02 +0400, vc wrote:
> > Hi,
> >
> > > From: devel-en-bounces at nemerle.org [mailto:devel-en-bounces at nemerle.org]
> > > On Behalf Of Kamil Skalski
> > > Sent: Sunday, July 02, 2006 9:08 PM
> > > To: devel-en at nemerle.org
> > > Subject: Re: [nem-en] Late Binding in Nemerle
> > >
> > > Generating such proxy classes should be relatively easy using a macro.
> > > def x = dynamic_implement (obj, IFoo, IBar, IWazz);
> > > x.foo();
> > > x.bar();
> > >
> > > would be quite nice. :)
> >
> > One question: where to take the information necessary to this macro?
> >
> > VladD2
> >
> >
> > _______________________________________________
> > https://nemerle.org/mailman/listinfo/devel-en
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
>
>
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list