Open source dmd on Reddit!

Jordan Miner jminer2613 at NOSPAM.students.pcci.edu
Sat Mar 7 20:48:11 PST 2009


Walter Bright Wrote:

> Daniel Keep wrote:
> > I use mixins with CTFE functions WAY MORE than I use them with templates.
> 
> I'm not surprised. I feel the template mixins were probably a mistake.

I like template mixins and use them. I don't use them much, but they are very useful for events (signals/slots) at least. The signals in Phobos uses template mixins, and I'm writing a GUI library where I'm using events similarly as a template mixin:

mixin Event!(whenMouseDown) mouseDown;
void whenMouseDown(MouseDownEventArgs e) { }

I don't think there is another way to get as nice a syntax, and events are important in a GUI. Though I still wish I could document the mixed-in templates... (bug #648)

With CTFE and mixins, I'm not thrilled with passing code around as a string (no syntax highlighting), even though it is really powerful. But I don't think I will mind much in D2 with token strings. Still, finding a better syntax for mixin(string) would be great.



More information about the Digitalmars-d-announce mailing list