run-time stack-based allocation

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Mon May 7 15:26:29 PDT 2012


Yes! I really want it! There are tons of instances when a heap
allocation is done instead of stack allocation because of dynamic size
alone. If its lifetime is limited by a scope (any scope) - it doesn't
belong on the heap!

On Tue, May 8, 2012 at 2:07 AM, deadalnix <deadalnix at gmail.com> wrote:
> Le 07/05/2012 13:58, Gor Gyolchanyan a écrit :
>
>> I'm working on dynamic memory layout manager. Simply put, it will
>> allow one to create and use struct types at run-time.
>> Normally, you create a struct at compile-time type by specifying an
>> ordered list of fields, each with its own type (basically a size) and
>> name.
>> You then access those fields by calling a compile-time evaluated dot
>> operator, which computes the address of the specified field given the
>> address of the struct.
>> What I'm trying to make is precisely that, except at run-time.
>>
>> My question is: what is the best way of allocating such a structure on
>> the stack? It will, of course, have a dynamically known size.
>>
>
> About that, I already had the need to return a variable that will be
> qualified as scope after the return.
>
> It would also be usefull to safely implement stack allocator.



-- 
Bye,
Gor Gyolchanyan.


More information about the Digitalmars-d mailing list