[fpc-pascal] Management operators question

Maciej Izak hnb.code at gmail.com
Fri May 25 14:03:12 CEST 2018


2018-05-25 12:19 GMT+02:00 Ryan Joseph <ryan at thealchemistguild.com>:

> Here’s a quick demo I typed up but I don’t understand why the init/dealloc
> count isn’t balanced. Calling the constructor seems to be the culprit, but
> why?
>

all is balanced :) you forgot to handle operator :

class operator Copy(constref src: TDynArray<T>; var dest: TDynArray<T>);

and

class operator AddRef(var a: TDynArray<T>);

for the line from example "d := TIntArray.Create([1, 2, 3]);" the "Copy"
operator is executed (you need to check when which operator is used - this
is the best way to learn, on the beginning it may looks a bit complicated):
so for each AddRef, Copy and Initialization the Finalization operator is
executed.

anyway you should not use management operators in FPC trunk, the work is
discontinued on the trunk and may be removed (not my fault - for one person
in FPC core with admin rights, emotional personal revenge and victimization is
more important than work and future of Pascal).

The management operators feature has not yet full potential, some related
things are not finished (for example FastRTTI to speed up all managed types
usage), all of my work will be continued in NewPascal.org project (default
field/property, new management operators, bug fixes for some problems,
smart pointers).

In the case of any questions you can use mORMot forum, sorry for
inconvenience! :(

NOTE: also rtl-generics/Generics.Collections is discontinued in trunk, so
any new collections, bug fixes and related compiler fixes can be found in
NewPascal and in https://github.com/maciej-izak/generics.collections (for
now it works for trunk and 3.0.4 but may stops to work with tunk/3.0.4 at
some point).

NOTE 2: I have hope at some point to merge back all my patches and features
with official FPC trunk.

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180525/2eeb7157/attachment.html>


More information about the fpc-pascal mailing list