opDispatch and compile time parameters

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 19 11:16:15 PDT 2015


On 10/19/2015 01:50 PM, Nikolay wrote:
> On Monday, 19 October 2015 at 08:41:46 UTC, Jack Applegame wrote:
>> D template system is very powerful.  This is more generic solution:
>>
>> http://dpaste.dzfl.pl/791c65d0e4ee
>
> Wow!
>
> I can't believe that it is possible and there is so straightforward way.
> You should post this answer to SO
>
> Thanks!

It is amazing indeed. We should make this a standard library artifact.

Tangentially related: since when we allow field initialization with new? 
I was surprised to see that this works:

struct A {
	int[] x = new int[10];
}

void main() {
	import std.stdio;
	A a;
	writeln(a.x);
}

After all that talk about default constructors that don't do anything, 
it's ironic I didn't know about this language change :o).


Andrei



More information about the Digitalmars-d mailing list