[fpc-pascal] Managed record questions

Ryan Joseph ryan at thealchemistguild.com
Thu Mar 8 08:07:48 CET 2018

> On Mar 8, 2018, at 1:48 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> You could use an include file containing both the declaration and implementation controlled by compiler defines together with a macro for the type name. 

That’s a nice trick. If those records get adopted something “managed record” would be really cool. They’re pretty new and I’m not sure if they’re being used yet.

> 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.

What’s the principle that says classes should always be on the heap? The old object style classes used to be on the stack but for some reason they decided change this to heap only. I didn’t really think much about it until I saw how c++ had this optional and then it occurred to me all the Create…Free blocks I’ve used so often that could just be on the stack instead. Point taken about it being lots of work to implement though.

Btw can you override the memory manager used for class constructors? If a class reused the same block of memory that would have a similar effect and useful for tight loops where you’re allocating/deallocating memory over and over again.

	Ryan Joseph

More information about the fpc-pascal mailing list