[nem-en] Late Binding in Nemerle
Arthur Peters
amp at singingwizard.org
Tue Jul 4 15:44:26 CEST 2006
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LateBinding.n
Type: text/x-nemerle
Size: 14003 bytes
Desc: not available
Url : /mailman/pipermail/devel-en/attachments/20060704/16a86f02/LateBinding-0001.bin
More information about the devel-en
mailing list