This Week in D May 28, 2017

Welcome to This Week in D! Each week, we'll summarize what's been going on in the D community and write brief advice columns to help you get the most out of the D Programming Language.

The D Programming Language is a general purpose programming language that offers modern convenience, modeling power, and native efficiency with a familiar C-style syntax.

This Week in D has an RSS feed.

This Week in D is edited by Adam D. Ruppe. Contact me with any questions, comments, or contributions.


In the community

Community announcements

See more at the announce forum.

Tip of the Week

I was asked on IRC this week for a technique to make a complex string mixin without exposing a helper function by name. private doesn't work, since privacy only takes effect across module boundaries, and the mixed in symbols are likely used in the same module... so how can we do it?

There's a really easy answer: use an anonymous function with mixin. The syntax looks very similar to common Javascript patterns - you must put parens around the function, as well as at the end of it to call it, like so:

// notice the paren before the function keyword...
mixin((function () {
	string code;
	// can be however complex you like...
	code ~= "int foo;";
	return code;
})()); // and the closing paren there, then the immediate call

The anonymous function will not be in scope, but can contain whatever code you need to build the string.

Learn more about D

To learn more about D and what's happening in D: