Am 10.10.2015 11:12 schrieb "Michael Van Canneyt" <mich...@freepascal.org>: > > > > 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 === >> {$MODESWITCH MANAGEMENTOPERATORS} >> 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 ?
I don't think a different type will be needed. Just allow those three operator overloads for normal records and have them be present in the Init RTTI of the record so that fpc_initialize(), fpc_finalize() and fpc_copy() can pick them up. This will be needed anyway should such records be placed in arrays or other records or classes. (Of course from great power comes great responsibility ;) ) > > That would mean that the managed pointer/class would be implemented internally using a 'managed record', correct ? I like this approach, quite ingenious :) It's similar to the approach we use at work in C++. Simplyfies things quite a bit when one doesn't have to deal with delete ;) Regards, Sven
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel