Hi Sven, Yes I knew the problem in the latter approach. However my thinking is that some features can be derived from others and I believe that this applies here too.
So by adding these extension to records and the operator overload the feature can be implemented as a library extension. Also those features might benefit others and also provide the groundwork for more improvements in the future. In any case, all proposals are better than embarcaderos so I don't complain. Thanks, Chriss Στις 21 Σεπ 2014 3:39 μ.μ., ο χρήστης "Sven Barth" < pascaldra...@googlemail.com> έγραψε: > On 21.09.2014 14:15, Chriss Kalogeropoulos wrote: > >> Hi Sven, >> >> This design means that old classes need to be subclassed in order to >> enable this feature, correct? >> Would it be possible instead of declaring this on the class definition, >> to declare it on the actual variable? Something like >> >> var aArcObj: TFooObj; refcounted; >> >> Or similar. >> >> This would allow the same classes to be used both ways. >> > > No. You would need to have a place where to store the reference count and > one of the objections some people have is the size increase of TObject if > it would get a RefCount field (which would be the only solution with your > approach). Also you'd need to take care that all variables where you pass > along your object instance are marked as refcounted. This just complicates > things too much (both for programmers using this as well as for the > compiler). > > Also how about a smart pointer record implementation with generics? Is >> it possible ? >> > > What's missing is the possiblity to hook into the initialization (unlike > interfaces, strings and arrays class variables fields are not initialized > with Nil) and finalization (you need to adjust the reference count) of > records. And also it's currently not possible to overload the assignment > operator if both types have the same record type. > > Regards, > Sven > _______________________________________________ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel >
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel