scope escaping

Benjamin Thaut code at benjamin-thaut.de
Thu Feb 6 13:25:42 PST 2014


Am 06.02.2014 21:26, schrieb Adam D. Ruppe:
> On Thursday, 6 February 2014 at 20:17:25 UTC, Benjamin Thaut wrote:
>> foo([1 2 3 4]); // allocates the array literal on the stack, because
>> it is scoped.
>
> Absolutely. In fact, generically, any scope item could be moved to the
> stack. We were just discussing in the chat room how scope = stack
> allocation and scope = don't escape the reference actually go hand in
> hand; they are not two separate features, stack allocation is an
> optimization enabled by the restriction... and the restriction is
> required by the optimization to maintain memory safety.

Count me in on supporting this feature. I played with writing a DIP for 
giving scope a meaning for quite some time. And the ideas are pretty 
similar to yours.

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list