www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - C++ Metaclasses proposal

reply Enamex <enamex+d outlook.com> writes:
PDF: 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0707r0.pdf
Reddit: 
https://www.reddit.com/r/programming/comments/6js4uv/metaclasses_in_c/

I thought a bit on possible patterns in D to accomplish the same 
without string mixins.

For example, defining the prototype `Foo_` then mixing in `mixin 
MyMetaclass!Foo_ Foo`.

Got stuck trying to 'forward' (or copy the implementation of) 
functions in `Foo_` into `Foo` after modifying them, though.

Besides trying to do it in D (please try still!), what do you 
think of the idea? In general and say versus a robust macro 
system with some level of access to CTFE? Or even just a good 
macro system (someone began discussing this on the reddit thread; 
talking about Racket macros).
Jun 27 2017
parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 27 June 2017 at 15:57:01 UTC, Enamex wrote:
 PDF: 
 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0707r0.pdf
 Reddit: 
 https://www.reddit.com/r/programming/comments/6js4uv/metaclasses_in_c/

 I thought a bit on possible patterns in D to accomplish the 
 same without string mixins.

 For example, defining the prototype `Foo_` then mixing in 
 `mixin MyMetaclass!Foo_ Foo`.

 Got stuck trying to 'forward' (or copy the implementation of) 
 functions in `Foo_` into `Foo` after modifying them, though.

 Besides trying to do it in D (please try still!), what do you 
 think of the idea? In general and say versus a robust macro 
 system with some level of access to CTFE? Or even just a good 
 macro system (someone began discussing this on the reddit 
 thread; talking about Racket macros).
Quite a lot of it seems doable with mixin templates and UDA reflection. Ethan Watson's dconf talk is a good point of comparison.
Jun 27 2017