[fpc-devel] Pascal Smart Pointers Idea + ARC implementation

Michael Van Canneyt michael at freepascal.org
Sat Oct 10 11:13:37 CEST 2015

On Sat, 10 Oct 2015, Maciej Izak wrote:

> I am working on smart pointers for FPC (something more than pure ARC for
> classes).
> This solution is full compatible with existing code base.
> I would like to know what do you think about my conception and work.
> First step is almost done -> new record operators:
> === begin code ===
> type // Record with automatic constructor and destructor
>  TValue = record
>    class operator Initialize(var aRec: TValue);
>    class operator Finalize(var aRec: TValue);
>    class operator Copy(constref aSource: TValue; var aDest: TValue);
>  end;
> === end code ===
> MANAGEMENTOPERATORS are quite simple to implement. MANAGEMENTOPERATORS were
> created initially for fast implementation of TValue in RTTI.pas, but they
> inspired me for smart pointers.

This part I understand, it is simple enough. A managed record type ?

> The second step is some concept of low level structures for smart pointers
> (in this conception we have two kinds of smart pointers - smart pointers
> for objects and smart pointers for pointers):

As I understand the code, this is the low-level basis for a managed pointer,
and by inference, a managed class. Is that correct ?

That would mean that the managed pointer/class would be implemented internally 
using a 'managed record', correct ? I like this approach, quite ingenious :)

If so, please put the activation of the managed pointer feature under a modeswitch, 
as Sven suggested. {$MODE DELPHINEXTGEN} or {$MODE OXYGENE} can simply allow this modeswitch.

And: keep up the good work :)


More information about the fpc-devel mailing list