dsimcha dsimcha at
Mon Aug 30 20:15:04 PDT 2010

== Quote from Nick Sabalausky (a at a.a)'s article
> "dsimcha" <dsimcha at> wrote in message
> news:i5hkea$2sud$1 at
> > I've been toying for a long time with the idea of a std.mixins for Phobos
> > that
> > would contain meta-implementations of commonly needed boilerplate code for
> > mixing into classes and and structs.  I've started to prototype it
> > (
> > So far I have a mixin for struct comparisons, which is useful if you need
> > a
> > total ordering for use with sorting or binary trees, but don't care
> > exactly
> > how that ordering is defined.  I've also got a mixin that converts a class
> > to
> > a Singleton, and uses thread-safe but efficient mechanisms to deal with
> > the
> > __gshared singleton case.
> >
> > I'm also thinking of creating some mixins to allow cloning of arbitrarily
> > complicated object graphs, provided that you don't stray outside of SafeD.
> > Is
> > this worth implementing or will it likely be solved in some other way at
> > some
> > point?
> >
> > Right now I'd just like to milk the D community for ideas.  What other
> > pieces
> > of boilerplate code do you find yourself writing often that the standard
> > library should help with?
> Definitely trace and traceVal/traceValCT from my lib:
> Every time I work on D code from a codebase that doesn't use my lib and I
> shouldn't/can't/don't feel like adding it as a dependancy, I find the lack
> of my trace and traceVal/traceValCT to be a real pain. Having it in the std
> lib would be *really* helpful, even for me. The traceMixin can be helpful
> too.
> Also, getter and getterLazy from the same module. I find the built-in
> property-definition syntax (even with the new @property) to be painfully
> verbose and non-DRY for simple cases (which in my experience are the most
> common ones - specifically, every time I want a publically-read-only field).
> The getter and getterLazy take care of that.
> The other stuff in that module are other mixins I've also found useful,
> although to a much lesser extent than trace/traceVal/getter/getterLazy.
> I'm completely ok with any of that being included in or adapted for phobos.
> Be aware though, I've recently converted it from D1/Tango to D2/Phobos, so
> some of it might not be completely D2-ified yet (though it does at least
> work on D2/Phobos).

Awesome.  Could you do me a favor, though?  Please put a license block in the file
just so it's absolutely clear to everyone, even far in the future when this post
is buried in the archives, that borrowing from it is fair game.

More information about the Digitalmars-d mailing list