Phobos for Review: std.buffer.scopebuffer

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Feb 7 16:59:33 PST 2014


On 2/7/14, 3:11 PM, Brad Anderson wrote:
> On Friday, 7 February 2014 at 23:10:50 UTC, Walter Bright wrote:
>> On 2/7/2014 2:14 PM, Brad Anderson wrote:
>>>
>>> There's always alloca :)
>>
>> alloca() cannot be used to allocate stack data in a function enclosing
>> the current one.
>
> Oh, right. Forgot about that.

You can with a default parameter...

void fun(void* sneaky = alloca(42));

will allocate memory on fun caller's frame and make it available to fun.

I've known this for a while and am not sure whether it's an awesome 
idiom of the spawn of devil.


Andrei



More information about the Digitalmars-d mailing list