[fpc-devel] Management operators AddRef and Copy vs Copy

Maciej Izak hnb.code at gmail.com
Mon May 2 21:31:46 CEST 2016


2016-05-01 12:14 GMT+02:00 Florian Klaempfl <florian at freepascal.org>:

> Am 25.04.2016 um 16:47 schrieb Maciej Izak:
> > Finally I've decided to use Clone and Copy (as proposed by Florian).
>
> Glad to hear :) Another thing: I wonder if those really need to be
> operators? In C++, "clone" is also only a special constructor.
>

I feel that "operator" is more correct than "constructor". Operators are
easier to read, any operator has unique name (for constructor/destructor,
unique name is not so obvious).

For new constructors/destructors (to replace class operators
Initialize/Finalize/Clone/Copy) is required new modifier (my candidate for
this is "default" or "managed"). Even our "special constructor" just looks
like another constructor, even with modifier. Additionally those
constructors (I mean management operators) are directly inaccessible for
normal "create" purpose. So that is also a little confusing... Anyway we
have class constructor which is also implicitly executed...

"Management operators" name is clear for me and very conclusive :), so I
like to keep them as operators.

> Should I adjust RTL inner functions to this? I mean renaming FPC_COPY to
> > FPC_CLONE and FPC_ADDREF to FPC_COPY.
>
> I wouldn't do this, it has been this way for years. Users who dig in
> this code, understand it, the others are not effected.
>

Ok I agree.

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160502/8909d298/attachment.html>


More information about the fpc-devel mailing list