Phobos for Review: std.buffer.scopebuffer
Marco Leise
Marco.Leise at gmx.de
Fri Feb 7 22:14:06 PST 2014
Am Fri, 07 Feb 2014 16:59:33 -0800
schrieb Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:
> 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
I only recently discovered this method, but put it to good use
as well:
https://github.com/mleise/fast/blob/master/source/fast/cstring.d#L134
--
Marco
More information about the Digitalmars-d
mailing list