[fpc-devel] Defer keyword
Sven Barth
pascaldragon at googlemail.com
Fri May 7 10:46:47 CEST 2021
Michael Van Canneyt via fpc-devel <fpc-devel at lists.freepascal.org> schrieb
am Fr., 7. Mai 2021, 08:14:
>
>
> 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 ?
>
As far as I remember there wasn't really any agreement.
> IIRC there was also the proposal that this could be done automatically
> using
> a keyword:
>
> var
> 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'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.
> I cannot speak for others, but I think 90% of potential use cases for ref
> counting
> would be covered like this in my code: objects that only live inside a
> procedure.
>
I think the same.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20210507/487ceef7/attachment.htm>
More information about the fpc-devel
mailing list