On Wed, Jun 19, 2019 at 5:45 PM Ben Grasset <operato...@gmail.com> wrote:

> On Wed, Jun 19, 2019 at 5:02 PM Ryan Joseph <generic...@gmail.com> wrote:
>
>> It’s used for making reference counted types at the user level.
>>
>
> I'm not sure why you'd necessarily need to implement Copy specifically for
> that kind of thing, though. Initialize and Finalize would be much more
> relevant, I'd say.
>

Also, either way, the "managed record" overhead really isn't great. Try
first un-commenting-out `S: AnsiString` in this Compiler Explorer example
<https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:pascal,source:'unit+Output%3B%0A%0A%7B$mode+ObjFPC%7D%0A%7B$modeswitch+AdvancedRecords%7D%0A%7B$ImplicitExceptions+Off%7D%0A%0Ainterface%0A%0Atype+TLetter+%3D+(A,+B,+C)%3B%0A%0Atype+%0A++TRecord+%3D+record%0A++++//S:+AnsiString%3B%0A++++Letter:+TLetter%3B%0A++++class+function+Make(const+ALetter:+TLetter):+TRecord%3B+static%3B+inline%3B%0A++++procedure+Proc%3B+inline%3B%0A++++class+procedure+DoIt(const+A:+array+of+TRecord)%3B+static%3B+%0A++++class+procedure+DoDoIt%3B+static%3B+inline%3B%0A++end%3B%0A%0Aimplementation%0A%0Aclass+function+TRecord.Make(const+ALetter:+TLetter):+TRecord%3B%0Abegin%0A++Result.Letter+:%3D+ALetter%3B%0Aend%3B%0A%0Aprocedure+TRecord.Proc%3B+%0Abegin%0A++WriteLn(%5BB%5D+%3C%3D+%5BA,+B,+C%5D)%3B%0Aend%3B%0A%0Aclass+procedure+TRecord.DoIt(const+A:+array+of+TRecord)%3B+%0Avar+Start,+Finish:+%5ETRecord%3B%0Abegin%0A++Start+:%3D+@A%5B0%5D%3B%0A++Finish+:%3D+@A%5BHigh(A)%5D%3B%0A++while+Start+%3C%3D+Finish+do+begin%0A++++Start%5E.Proc()%3B%0A++++Inc(Start)%3B%0A++end%3B%0Aend%3B%0A%0Aclass+procedure+TRecord.DoDoIt%3B+%0Abegin%0A++DoIt(%5BTRecord.Make(A),+TRecord.Make(B),+TRecord.Make(C)%5D)%3B%0Aend%3B%0A%0Aend.'),l:'5',n:'0',o:'Pascal+source+%231',t:'0')),k:57.25490196078431,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:fpc304,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'0'),lang:pascal,libs:!(),options:'-Ci-+-Cr-+-g-+-CX+-XXs+-O4',source:1),l:'5',n:'0',o:'x86-64+fpc+3.0.4+(Editor+%231,+Compiler+%231)+Pascal',t:'0')),k:42.74509803921569,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4>,
and then afterwards re-commenting-out `{$ImplicitExceptions Off}`.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to