XSharpPublic icon indicating copy to clipboard operation
XSharpPublic copied to clipboard

Implement DIM array with StackAlloc in the background

Open RobertvanderHulst opened this issue 3 years ago • 0 comments

At this moment, DIM arrays are allocated in the heap. They should be allocated on the stack This code:

   VAR x := StackAlloc<DWORD>(10) 
   LOCAL dim y[10] as DWORD

Now produces (in C#)

uint* x = stackalloc uint[10];
uint[] y = new uint[10];

It would be nice if the DIM array is also on the stack. The only problem with that is that this is only allowed in .Net Core or later, or with the compiler option /unsafe enabled.

RobertvanderHulst avatar Jan 06 '23 16:01 RobertvanderHulst