[fpc-pascal] C# stackalloc

Ryan Joseph ryan at thealchemistguild.com
Sat Jun 2 08:01:47 CEST 2018


As a sanity check for myself if you remember a while ago I posted about an idea for “stack aliases” to override the memory allocation for classes. No one really liked the idea and lots of potential safety concerns were raised (fair criticisms).

By random chance today I came upon this feature of C# which basically does the same thing I was suggesting, as a way to override the default functionality of C# to allocate everything on the heap and garbage collect later. The reason stated for the feature is because it’s an optimization over the default heap-only allocation enforced for arrays.

So it looks like my idea wasn’t that crazy after all. ;) Granted C# needs this feature more than FPC does because C# amazingly can’t allocate arrays on the stack otherwise (now that’s crazy!) but never the less the inclusion of “stackalloc” in C# gives the idea some credibility for FPC.

https://www.c-sharpcorner.com/uploadfile/GemingLeader/creating-a-stack-based-array/

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list