[fpc-pascal] Managed properties idea
michalis.kambi at gmail.com
Fri Oct 6 21:49:34 CEST 2017
2017-10-06 20:52 GMT+02:00 Marcos Douglas B. Santos <md at delfire.net>:
>> In this case, in which you indeed want two of these features simultaneously,
>> I advise COM interfaces myself :) That's why they are documented after all.
> I can use it only to use reference counting.
You can, but it's a little uncomfortable.
If you use interfaces only for reference counting (not to share the
API between some unrelated classes), then you define a single
interface for each single class, repeating the same API -- methods,
properties. It's possible, but it's just a lot of work. I have a lot
of classes in my engine, and FPC RTL, FCL, Lazarus LCL define many
more classes --- wrapping them all in an equivalent interface, only to
get reference-counting for them, would imply a lot of work and
In contrast, something like C++ "shared pointer" is a feature that can
be applied to any existing class, without the need to repeat it's API.
See e.g. https://en.wikipedia.org/wiki/Smart_pointer . And once we
have management operators (see Sven's pointers), we can implement
something like this in Pascal. So you could use something like
"TSharedPointer<TStringList>" and you get a reference-counted instance
More information about the fpc-pascal