[fpc-pascal] Class constructor called unconditionally

Maciej Izak hnb.code at gmail.com
Thu Mar 31 17:55:49 CEST 2016


2016-03-31 17:06 GMT+02:00 Michael Van Canneyt <michael at freepascal.org>:

> I imagine so, yes.
>
> It is one of the reasons why I don't really see the usefulness of this
> construct, except that it looks OOP-ish.
>
>
It is mostly for initialization "class var" related stuff inside records
and classes. Very usefully especially with generics.

Even more - there is no workaround for class constructor/destructor when
generics are used (more details in Generics.Collections for example for
"cuckoo" dictionary).

Current implementation is DEFINITELY buggy and mentioned in topic behavior
should be reported as bug. Class constructor/destructor should be used only
when type is somehow used in code or when is used directive like
{$STRONGLINKTYPES ON} (which FPC don't have).

another bugs related to class constructor/destructor:
http://bugs.freepascal.org/view.php?id=28911
http://bugs.freepascal.org/view.php?id=29245

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160331/fa98e07c/attachment.html>


More information about the fpc-pascal mailing list