[fpc-pascal] Stack alias for ARC like memory management?

Michael Van Canneyt michael at freepascal.org
Wed Apr 25 14:05:40 CEST 2018



On Wed, 25 Apr 2018, Ryan Joseph wrote:

>
>
>> On Apr 25, 2018, at 6:14 PM, Adrian Veith <adrian at veith-system.de> wrote:
>> 
>> If you know what you are doing, you have exactly the "object" type for
>> that. You can allocate them on the stack or heap and you can inherit
>> from them, when you need virtual methods the initialization is a bit
>> strange (and if you need performance virtual methods are wrong anyway).
>> The benefit is better performance when needed. The downside is that they
>> are more unsafe to use than "class" type and you should now what you do.
>> If I need a cheap (performance wise) "procedure of object" for example,
>> that can't escape from the scope I use them instead of a class:
>
> Objects are not a complete implementation and lack features of classes (no interfaces mainly and constructing requires the new keyword). The syntax I propose lets you allocate classes on the stack on a per-request basis which means you can use the class on the heap when you need to pass it around, or on the stack when you know the life cycle of the class during compile time.
>
> Isn’t that a better option then using Objects and getting stuck with their syntax?

No, because it introduces additional complications.

We can think of extending the features of objects or advanced records.
Your proposal entails a very different model of handling, 
which matches more how objects and records are currently handled.

Michael.


More information about the fpc-pascal mailing list