More useful fixed-size array literals
Benjamin Thaut via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 31 02:13:01 PDT 2014
Am 31.05.2014 11:08, schrieb bearophile:
>> int foo(scope int[] items) @nogc {
>> return foo.sum;
>> }
>
> That was:
>
> return items.sum;
>
> Bye,
> bearophile
Well obviously the std.algorithm sum would also be annoted with scope.
Because it doesn't escape it either. I don't see the problem here. And
in case you really want to escape it, you need to .dup it.
A additional advantage of my solution is, that the compiler can prove it
to be @safe. Your solution does not allow that.
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d
mailing list