[fpc-devel] Management operators : Copy and Clone confusion...

Michael Van Canneyt michael at freepascal.org
Thu Jan 19 10:44:31 CET 2017



On Thu, 19 Jan 2017, Maciej Izak wrote:

> Hi,
>
> in patch/feature proposed in http://bugs.freepascal.org/view.php?id=30687
> we have Copy/Clone operators naming convention proposed by Florian (my
> initial idea was AddRef/Copy).
>
> I'd like to say that Copy/Clone naming convention is terrible in practical
> usage. :( As the main author I have many troubles and I have always
> confusion >.< I always must to check which is for adding reference and
> which one is for copying...
>
> For example Paul Ishenin said in previous discussion ("ANN: Management
> operators - final patch") : I know Florian insisted on Copy and Clone names
> but still for my taste it would be the best to have conformity between
> compiler and RTL.
>
> In current FPC implementation of management operators "Copy" operator is
> *always* used for increasing reference count and "Clone" operator is used
> to create copy... In this area I have objections for my own patch.
>
> Maybe someone have other ideas? Maybe we could back to AddRef/Copy which is
> RTL compatible and is more "real life" friendly?

At the risk of writing nonsense:

I would think that a method name should give a clue as to what it actually does.
In that sense AddRef/Clone seems better to me ?
(unless Copy does something else besides increasing the ref count ?)

AddRef is clear to anyone, I think.

If I see "Clone", I immediatly think of an object whose properties are a copy of
the original, but which otherwise has nothing to do with the original.

Michael.



More information about the fpc-devel mailing list