A lightweight module for class extensions in D
Gregor Richards
Richards at codu.org
Sun Dec 7 07:48:31 PST 2008
Christian Kamm wrote:
> I had done something similar, albeit using D2 and traits, in
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=56018
>
> It's good to see it's possible in D1! The main advantage of __traits seems
> to be that you can avoid building a lookup table and thereby simplify the
> user interface. On the other hand, your approach will probably work even
> when the extension methods are defined in different modules, as long as the
> one with the extensions mixin is imported?
>
Yes.
The best solution IMHO would be to be able to declare things to be in
the vtable that aren't functions (but are, for example, a pointer to
some area of globally-accessible-and-writable memory). Then you could
effectively have a sub-vtable. But alas, 'tis not possible :)
- Gregor Richards
More information about the Digitalmars-d
mailing list