I have made a discovery

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 18 19:45:57 PDT 2015


On Sunday, 19 April 2015 at 02:24:06 UTC, Rikki Cattermole wrote:
> 	int[3] values = allocate!(int[3]);

Why would you ever do that? int[3] is statically allocated....


auto values = allocate!(int[])(3);

would make a lot more sense, then values would be typed perhaps 
to int[], but also it might be typed to something like 
RefCounted!(int[]) or Unique!(int[]) or something, so the 
requirement to deallocate is encoded right there in the type and 
thus known to the compiler.

But even `int[] values = new!(int[])(3);` is very similar to the 
built-in syntax and can do exactly the same thing - while also 
being changeable to a new scheme by importing a different module.


More information about the Digitalmars-d mailing list