I just have to say that string mixins rock
Philippe Sigaud
philippe.sigaud at gmail.com
Wed Jul 25 23:48:33 PDT 2012
On Thu, Jul 26, 2012 at 8:24 AM, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> They've made my life way easier on a number of projects lately - particularly
> involving parsing.
Yeah D!
Nice use of mixins. I was a bit meh at the beginning (2009?) but the
combination of templates, CTFE which can be used to generate the
string and/or tansform it and mixins to inject them on code is simply
wonderful.
> On top of that, all I have to do is alter the few templates that I use to
> generate the strings, and I can make it print out the value, or append it to
> another buffer, or assign it to a corresponding field in a struct, so on and so
> forth. It saves quite a bit of code duplication, and makes it _really_ easy told
> change what a whole ton of lines of code do.
You might want to use debug/log flags like this:
mixin(parseUEV!("bit_depth_luma_minus8", Debug.yes));
and then activate debugging/logging with static ifs inside the template.
> I've got a variety of such mixins in a variety of projects, and they really
> help simplify the code. This is one feature in D that's really made my life
> easier.
Ditto. Took me a while to be convinced (assembling code as strings?
Ewww, oh gross!), but now I'm sold.
Philippe
More information about the Digitalmars-d
mailing list