[fpc-devel] Pascal Smart Pointers Idea + ARC implementation
hnb.code at gmail.com
Sat Oct 10 19:09:21 CEST 2015
2015-10-10 18:40 GMT+02:00 Sven Barth <pascaldragon at googlemail.com>:
> Am 10.10.2015 18:19 schrieb "Maciej Izak" <hnb.code at gmail.com>:
> > class operator TSmartPtr<T>.Copy(constref aSource: TSmartPtr<T>; var
> aDest: TSmartPtr<T>);
> > begin
> > if aDest.RefCount <> nil then
> > Finalize(aDest);
> > if aSource.RefCount <> nil then
> > InterLockedIncrement(aSource.RefCount^);
> > aDest.RefCount := aSource.RefCount;
> > aDest.Instance := aSource.Instance;
> > end;
> Shouldn't it be SmartFinalize here as well instead of Finalize?
Yes, it should be SmartFinalize.
> While I see and understand your reasoning behind it I don't really like
> it... There needs to be some better way for this... hmm... :/
I am only sure about MANAGEMENTOPERATORS.
instead of "default" field we can introduce:
operator Dot: T;
operator Dereference: T;
operator Addr: T;
operator DoubleAddr: T;
operator DefaultImplicit: T;
operator TypeInfo: PTypeInfo;
but this solution is much slower. btw. we can introduce also this operators
for better control of "default" field. (all of above operator have higher
priority than "default" field and "default" field has bigger priority than
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel