<p dir="ltr">Hi Sven,</p>
<p dir="ltr">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. </p>
<p dir="ltr">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.</p>
<p dir="ltr">In any case, all proposals are better than embarcaderos so I don't complain.</p>
<p dir="ltr">Thanks, <br>
Chriss<br>
</p>
<div class="gmail_quote">Στις 21 Σεπ 2014 3:39 μ.μ., ο χρήστης "Sven Barth" <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>> έγραψε:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On <a href="tel:21.09.2014%2014" value="+12109201414" target="_blank">21.09.2014 14</a>:15, Chriss Kalogeropoulos wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Sven,<br>
<br>
This design means that old classes need to be subclassed in order to<br>
enable this feature, correct?<br>
Would it be possible instead of declaring this on the class definition,<br>
to declare it on the actual variable? Something like<br>
<br>
var aArcObj: TFooObj; refcounted;<br>
<br>
Or similar.<br>
<br>
This would allow the same classes to be used both ways.<br>
</blockquote>
<br>
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).<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also how about a smart pointer record implementation with generics? Is<br>
it possible ?<br>
</blockquote>
<br>
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.<br>
<br>
Regards,<br>
Sven<br>
______________________________<u></u>_________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" target="_blank">http://lists.freepascal.org/<u></u>cgi-bin/mailman/listinfo/fpc-<u></u>devel</a><br>
</blockquote></div>