[fpc-pascal] Managed record questions

Ryan Joseph ryan at thealchemistguild.com
Thu Mar 8 08:43:08 CET 2018



> On Mar 8, 2018, at 2:20 PM, Maciej Izak <hnb.code at gmail.com> wrote:
> 
> Management operators are almost unusable without default field/default property. How it works you can see here :
> 
> https://github.com/maciej-izak/PascalSmartPointers
> 
> the examples can be tested with NewPascal for now. The simplified inheritance for records can be simulated by "default field", but the main idea is to use mix of generics/management operators and default field. "default field" has very long list of potential usages. 

I see, you’re using a generic record to wrap another type. That’s an interesting solution but I wonder if the heavy use of generics will be cumbersome in practical implementations. I need to try it I guess. :) Thanks.

> "ARC" objects are for sure possible to achieve but in other way (by new feature called concepts). Management operators are intended as base for nullable types, smart pointers and can be used for ARC classes too but the real and proper ARC classes should be implemented in other way. In this are is a lot of R&D - you need to remember that the priority is to keep backward compatibility - we don't want Delphi NEXTGEN for all modes - the main advantage of FPC is freedom of choice :)

In many cases I don’t actually need anything on the heap and a record could be used instead but because of limitations on records in Pascal I need a full class. Doing the ARC route is just solving a problem I created by the fact I used a class instead of a record in the first place. c++ solves this by letting you keep the class on the stack or the heap depending on how you want it’s memory managed. That was a superior choice in my opinion but I understand implementing that in Pascal would be a massive overhaul and probably not worth it.


Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list