Forum > General

Management operators and classes?

(1/3) > >>

soerensen3:
Hi,

is something like this also possible for classes?
http://wiki.freepascal.org/management_operators

I hope it to simplify my managed pointer type which works but is way to complicated to use.

I only know of interfaces but I never understood the way reference counting works with them. It seems to be quite complicated: https://www.freepascal.org/docs-html/ref/refse92.html

Thaddy:
In trunk this is fully supported and both Maciej (the author, a.k.a HNB) and me already gave some powerful examples on this forum.
It still needs an extra pseudo reference, though..

hnb:
you can try this library : https://github.com/maciej-izak/PascalSmartPointers

especially this example should be interesting for you : https://github.com/maciej-izak/PascalSmartPointers/blob/master/examples/SmartObj01.pas

note: code with "default field" will work only with http://newpascal.org/ not with FPC stable nor FPC trunk.

soerensen3:
Thank you for your answers.
@Thaddy: I couldn't find it somehow, all I could find was the code with the records. I was wondering if these operators also work on classes directly but probably not. This way I could get rid of the pseudo reference. With pseudo reference you mean the record, right?

@hnb: That's the repo that I was looking for. Too bad with the default field but I think it's still useful, because assigning should still work. For now I would like to keep my code compatible but I will definitely give NewPascal a try.

hnb:
you can't use management operators in classes, this is possible to implement but may be not worth (I am still considering few scenarios).

maybe someday close cooperation with FPC core team will be possible again (I have hope so), but for now too many bad emotions around, so rather I wouldn't expect any of my new feature (nor any activity) in FPC trunk in near future.

Navigation

[0] Message Index

[#] Next page

Go to full version