My Long Term Vision for the D programming language

Elronnd elronnd at elronnd.net
Thu Nov 25 09:29:49 UTC 2021


On Thursday, 25 November 2021 at 02:32:41 UTC, max haughton wrote:
> the key thing with this scope transformation isn't stack 
> allocation but rather moving the allocation anywhere other than 
> the GC.

I am not quite sure what you are saying.  Are you saying that:

1. The problem is moving the allocation somewhere other than the 
gc, including potentially to the stack, or to an alternate heap, 
or to somewhere else; or,

2. Converting allocations from gc to the stack is fine; but 
moving them anywhere else is problematic

In either case, this compiles currently and produces GC-free code:

@nogc:
void f(scope int[] x);
void g(int x, int y) { f([x, y]); }

I'm not sure where you would want to move scope allocations to 
aside from the stack, as scope guarantees LIFO, and so is the 
perfect fit for a stack.  Perhaps an alternate stack (cf 'brk') 
managed in druntime, to avoid stack overflow?  That would be 
good, but is hardly a challenging transformation if you can 
already produce regular stack allocation.


More information about the Digitalmars-d mailing list