mixin + CTFE, to big a hammer??

BCS BCS at pathlink.com
Fri Mar 2 09:18:43 PST 2007


Mikola Lysenko wrote:
> kris Wrote:
> 
>>D mixin, in it's current guise, is about equivalent to crack-cocaine. 
>>Easily the worst thing that happened to the language, IMO.
>>
>>Just say no
> 
> 
> At this point I am inclined to agree.
> 
> Initially, I was skeptical about mixins, but I was also intrigued by the potential meta programming improvements.  One important problem that I do not know how to solve without mixins is the creation of a set of patterned names.  As a case study think of the swizzle operators for a vector class.  You need functions like, x, yx, xyz, zyx, zzy etc.  These functions can be trivially enumerated by a computer program, which makes them good candidates for automatic generation.  The mixin statement is enormously helpful in simplifying this code.
> 
> However, there are simply too many hazards with the mixin statement.  Mixins are not lexically closed - you can very easily mess with names from the exterior scope.  They suffer many of the problems encountered in the C preprocessor.  Excessive use of mixins and metaprogramming causes compile times to balloon to ridiculous lengths, far exceeding even the horrors of C++.  The net effect is that they undo many of the advantages D once held.
> 
> My belief is that the basic problems with mixins result from their reliance on string manipulation for meta programming - rather than syntactic and structural concepts.  If we want to create mixin like behaviors (and I think that ultimately it is a good goal) they need to be presented in the logical context of a program manipulator - not a text processor.  The current mixin syntax needs to be aborted before we go any farther down this line of thought.  The longer it sticks around in the language, the harder it is going to be to kill. 
> 
> I vote it gets axed in the next release.
> 
> -Mik

There is one thing mixin do vary well from what I've seen is symbol 
access. If mixins are cut back, this should stay. Maybe as a 
MixinIdentifier rule in the grammar. I would hazard to say that this 
will get better than 80% of the expressiveness of mixins with much less 
then 20% of the problems.



More information about the Digitalmars-d-announce mailing list