Am 08.03.2018 04:44 schrieb "Ryan Joseph" <r...@thealchemistguild.com>:
1) Given the example below we have a template for a standard ref counted record. Shouldn’t there be some “meta record” type that implements this automatically? I’m thinking about adding this to some types but the idea of recreating this same template every time is daunting and records don’t have inheritance so there’s no way to capture it once. You could use an include file containing both the declaration and implementation controlled by compiler defines together with a macro for the type name. 2) This new feature begs the question why can’t classes be kept on the stack OR the heap now like in c++? There’s countless times I allocate a class on the heap (because you have to) when I could have kept it on the stack and the compiler called some destructor it when it goes out of scope. It’s such a common pattern and a shame to be dynamically allocating/freeing memory every time. C++ really cleans up a lot of memory garbage by making it an option of how your classes are allocated but FPC is stuck in the middle with structs/classes being different enough you need to decide once and commit to that memory management scheme for all uses. No, this doesn't beg the question, because Object Pascal classes are designed in the principle to reduce on the heap. Changing this would not only mean quite some changes in the compiler/RTL with no real gain, but it would also change a core aspect of the Object Pascal language. Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal