On Wednesday, 12 April 2017 at 21:40:48 UTC, bluecat wrote:
What are some features that you have discovered that you would like to share with the community? For me, one thing I found interesting was the ability to define structures dynamically using mixins:import std.stdio; import std.format: format; template MakePoint(string name, string x, string y) {const char[] MakePoint = "struct %s {int %s; int %s;}".format(name, x, y);} mixin(MakePoint!("Point", "x", "y")); void main() { auto pt = new Point; pt.x = 1; pt.y = 2; writefln("point at (%s, %s)", pt.x, pt.y); }
I really like the ability to pass delegates as `alias` template arguments. This allows me to pass these delegates as templates, and the "higher-order" template can instantiate them multiple times with multiple types: https://dpaste.dzfl.pl/e2a7a252b5cc
