On Fri, 7 May 2021, Sven Barth via fpc-devel wrote:

In my opinion the better solution is to continue the road that Maciej started and to implement that "default field" concept together with operator hoistening so that records with management operators can be used as containers. This is essentially the way it's done in C++ as well (e.g. we use that extensively at work), but it needs some questions solved for the default field functionality. This way the functionality is definitely optional and can be controlled per-instance instead of per-type. What it wouldn't solve however would be the assignment problems ("wrapped" to non-"wrapped" instance) though that could be probably be more or less solved by only allowing an explicit conversion to the non-"wrapped" instance.

I thought it was agreed at the time that this was the most viable way
forward ?

IIRC there was also the proposal that this could be done automatically using
a keyword:

  SomeClass : TSomeClass; dispose;

The compiler can internally create the management record with a single default field and the needed management operator, so the user does not need to create all that.

I cannot speak for others, but I think 90% of potential use cases for ref 
would be covered like this in my code: objects that only live inside a

fpc-devel maillist  -  fpc-devel@lists.freepascal.org

Reply via email to