there is the possibility In C++ to create a Class on the stack (they are by default always on the stack) and still enable full inheritance, polymorphie, operator overloading etc…
but if you need them to be on the heap, you must declare a pointer/Reference to that Class. FPC/Delphi have smth similiar which are called “objects” which I sadly miss in Oxygene, since having the power to express a datastructure everywhere in memory is really really powerful especially when u work on more low-lvl stuff (like myself right now with an engine im involved at) to have proper optimization control, ,and ALSO, I would love to add, if you would consider making the effort to allow the newly released “Management Operators” from Delphi to define how records are accessed, assigned and finalized. Also a very important low-lvl feature. IF you consider implementing those, I would really love to see them find their way also to the “stackbasedClass” type, if you also decide to implement this, since as I mentioned, it allowes for a lot of nice and important shinenigans
So to summarize:
- Implement a new Delphilike-object to store a class on stack (but not with the class keyword ofc and the usual support of
interfaces, class-operators, polymorphism, management-operators(see delphi example), move-semantics(C++))
- Allow management-operators(see delphi example), move-semantics(C++) also for records
Not gonna lie, if this could find the way to Island, I would be a happy panda, since this enables a big box of potentials for High optimizations within Island! And it would be a nice ChristmasGift xD
PS: some may know them, but for the ones who do not: std::move is a powerful intrinsic which allows the faster realloc of data when the “assign” operator is overloaded for a custom class/record then in delphi where you can say that if a class contains a string and u dont want that string to be copied everytiome u make a copy of that class to another instance (im talking now in case of C++…) you just overload the “assign” operator and use the std::move(myString) to move it to another location, so u dont have to copy each time a custom-length string which is much more performant than a copy.
I hope I could explain all that somewhat decently and that atleast it raises some attention
Have a blessed week/time/Christmastime!
PS: for more information, i have read about an already existent thread in the FPC forum, apparently it is discussed there aswell as i found out, for more information look: How optimized is the FPC compiler (freepascal.org)