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

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

As far as I remember there wasn't really any agreement.

Can be, I was not sure... I remember this path was investigated.

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

   SomeClass : TSomeClass; dispose;

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

I'm not aboard with such a keyword. The compiler should provide the
necessary language mechanisms (default field, operator hoisting) and then
there should be a default implementation as part of the RTL. There is no
need to hide this behind a keyword, attribute or whatever.

There is:

Using a keyword, the compiler could also optimize things by simply initializing and freeing the instance if the usage of the object in the procedure allows it; it would allow to skip the record and operators and whatnot.

I'm not proposing to abolish the record approach, just an additional automatism that will use it, but allows to skip it for simple enough cases which are
probably the largest use-case.

Don't forget that the record/management operator approach will again blow up binary size; for every variable declared like this you risk creating a new type.

The introduction of generics and their abundant use in Delphi has noticably slowed down the compiler and increased binary sizes. To my dismay, compile times of 20 seconds up to 2 minutes have become not uncommon in Delphi. Something almmost unthinkable in D7 days.

If that can be avoided by use of a keyword for 90% of use cases, I think it is worth thinking about it and not dismissing it offhand.

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

Reply via email to