pure static

Meta jared771 at gmail.com
Mon Jan 6 18:27:40 PST 2014


On Tuesday, 7 January 2014 at 00:54:10 UTC, bearophile wrote:
> Meta:
>
>> Why not just return arr.dup instead? You're returning a slice 
>> of a stack-allocated array, so of course you shouldn't write 
>> code like this.
>
> In certain critical code paths heap allocations are evil 
> (perhaps even if your generational GC has a stack-like nursery, 
> that currently the D GC doesn't have) :-) And you also want to 
> minimize copies and initializations.
>
> Bye,
> bearophile

But is it ever legal to return a local stack-allocated static 
array from a function in D? Won't that entail a copy either way?


More information about the Digitalmars-d mailing list