std.mixins

dsimcha dsimcha at yahoo.com
Tue Aug 31 11:03:52 PDT 2010


== Quote from Lutger (lutger.blijdestijn at gmail.com)'s article
> Instead of std.mixins, perhaps it is better to fold the code with std.typecons
> or create new modules as needed (std.pattern?).

I initially thought std.mixins would be a good idea, since it would be a one-stop
shop for all kinds of misc. boilerplate code that doesn't really fit anywhere
else, but the consensus seems to be that this is a bad way to define a module.
I'll reconsider.

> There is also some private
> boilerplate code here and there in phobos that help with ctfe and
> metaprogramming, some people may also find that useful if packaged as a seperate
> utility module.

Yea, that should probably be a todo.

> My suggestion is to include a mixin for unrolling loops.

I thought about this.  Simple loop unrolling doesn't seem like a very useful
optimization on modern hardware because branch prediction and pipelining have
gotten so good.  It can still be useful if you also change the loop body a little,
for example using multiple accumulators to increase instruction level parallelism,
but this is hard to write generically.  I can't think of a way to write such a
mixin such that it would be both generic and useful.

> Also something like
> defineEnum, but for generating bitflags. (I have some code for this).

Can you give an example?  I'm not sure what you mean.

> I would
> also like to see a mixin for generating the boilerplate for decorator
> forwarding, which is annoying. This should be not that hard with the existing
> code in std.typecons.

Shouldn't opDispatch basically handle this for you?  I think that's one reason why
it was created.

> Furthermore (not mixin related perse) more phobos code could be made to work at
> compile time. I am pleasantly surprised a lot has improved in this respect the
> last few releases, but more can be done (sorting for example is useful and
> possible).

Slowly but surely...

> The dranges project at dsource is awesome, it wouldn't hurt to put
> some of that good stuff in phobos.

Agreed.  It's Philippe Sigaud's project and he's been recently added to the roster
of Phobos devs.  I assume he intends to integrate at least the more generally
useful parts of dranges eventually.


More information about the Digitalmars-d mailing list