<div dir="ltr">Hi,<div><br></div><div>Finally I have a working implementation (not published yet) of Smart Pointers/ARC objects and Nullable (Nilable?) types. I think is worth to discuss a little about new "default modifier" (which is strictly related to mentioned structures). If needed I can correct details.</div><div><br></div><div>As you know (or not) all is based on new modifier - "default" for fields. Overriding operators like "." or "^" is complicated and not obvious in Pascal world.</div><div><br></div><div>The "default" modifier is inspired by "default" modifier for indexed properties. All of my work is (I hope so) natural for Pascal language. All FPC tests pass fine (phew!). The idea is quiet simple:</div><div><br></div><div>"If all fails - try to use default field".</div><div><br></div><div>Example implementation of SmartPointers and SmartObjects available at:</div><div><br></div><div><a href="https://github.com/maciej-izak/PascalSmartPointers">https://github.com/maciej-izak/PascalSmartPointers</a> (see OUTPUT on the end of each of file)<br></div><div><br></div><div>Tests (very good way to see how it works. NOTE: I need to add few other tests for functions with var/const/out, "for in do" loop and for arrays and indexed properties - help with additional tests is welcome):</div><div><br></div><div><a href="https://github.com/maciej-izak/PascalSmartPointers/tree/master/tests">https://github.com/maciej-izak/PascalSmartPointers/tree/master/tests</a><br></div><div><br></div><div>The way how to obtain pointer can be a little confusing for most of Pascal programmers. Anyway nothing new for Pascal language. In Pascal we have little known @@ operator to get pointer to variable which handle pointer to procedure/function. For records with "default field" @ means "get pointer to default field" and @@ means "get pointer to record".<br></div><div><br></div><div>Any questions and suggestions are welcome!</div><div><br></div><div>Side note: as side effect of new feature we can implement very compatible ARC objects compatible with Delphi without breaking existing code base and without ugly additions for TObject like:</div><div><br></div><div><div>    function __ObjAddRef: Integer; virtual;</div><div>    function __ObjRelease: Integer; virtual;</div></div><div>    property RefCount: Integer read FRefCount;</div><div>    procedure DisposeOf; // that can become also part of TObject<br></div><div><br></div><div>All can be delegated into record (record with default field works like proxy, note: each of method/field/property/operator of record has higher priority than "default field object"). We can omit easily TComponent problem for ARC compiler like mentioned here (maybe we can add some hidden field for TObject similar to hfMonitorOffset from Delphi to point proxy record for destroy notification - maybe as part of TMonitor):</div><div><br></div><div><a href="https://plus.google.com/+DalijaPrasnikar/posts/3CUnrZam6zp">https://plus.google.com/+DalijaPrasnikar/posts/3CUnrZam6zp</a> (see comments)<br></div><div><br></div><div>more info about DisposeOf:</div><div><br></div><div><a href="https://plus.google.com/+HoracioJoseCavalcantiFilho/posts/Nhp7wbHX2hM">https://plus.google.com/+HoracioJoseCavalcantiFilho/posts/Nhp7wbHX2hM</a> (see comments)<br></div><div><div><br></div>-- <br><div><div dir="ltr"><div>Best regards,<br>Maciej Izak</div></div></div>
</div></div>