December 23, 2007
"Derek Parnell" <derek@psych.ward> wrote in message news:79knrjyy3vnp$.1vie66jlel0bb.dlg@40tude.net...

>    scope int[2]f = [a,b];

It's syntactically legal, but it won't delete the array at the end of the scope.  Dumb, I know.


December 24, 2007
Jarrett Billingsley wrote:
> Before anyone says "but the compiler could detect those", what about in this case:
> 
> extern(C) someFunc(int* arr, int len);
> 
> void myFunc(int x, int y)
> {
>     auto arr = [x, y];
>     someFunc(arr.ptr, arr.length);
> }
> 
> The compiler knows nothing about what someFunc does and can't tell if it stores that array away in some global variable or something, therefore it can't tell if this is legal code.  (This is why side effects are bad, the FP programmers tell us..) 

If I am not mistaken, your example here does the "bad thing" already, no
matter if it allocates heap to initialise the variable or not.

regards, frank
1 2
Next ›   Last »