I have made a discovery

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 18 19:50:58 PDT 2015


On 19/04/2015 2:45 p.m., Adam D. Ruppe wrote:
> 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.

I couldn't fully remember the syntax. So I went with closest I thought 
it was to make the point.


More information about the Digitalmars-d mailing list