[fpc-devel]Proposal for audo-destructors

Marco van de Voort marcov at stack.nl
Sun Sep 12 19:11:27 CEST 2004

> The problem actualy is not in automated destructors, 
> but in that the Class
> types are actually pointers in Delphi OO model. That 
> IS the hack, that makes some
> tasty stuff impossible (RAII)

Afaik RAII is simply that automated stuff is guaranteed finalised in a
predicatable time? (unlike e.g. Java where the GC can defer disposing an
object forever)

One can perfectly code in FPC such that way. Of course one should write
sensible code, but a few automated types won't help with that.

IMHO the C++ way is not safer this way either, since there are numerous
gotcha's. It mainly improves the amount of code one has to write, not
safety. However a sound alternative is to put this into the IDE.

IIRC smartpointers were added to C++ drafts to get a better security rating
according to American military standards. 

> or unconvinient (programmer has not to forget destructor).

Programmer must not forget to declare auto either. If you really want to
avoid human mistakes, automated code analysis systems is a wiser way to go.

> Just have a look at "classes" and "pointers to classes" in C.

Yes. BP did that too, (static objects are still possible in FPC that way)
luckily Delphi improved on that.

> The problem is that we have no similiar functionality for first ones in
> Pascal

As said, IMHO we don't need it. It is a feature for a different kind of
language. Ok, C++ added it, but C++ pretty much added everything they could
find :-) That's aggregation, not design.

More information about the fpc-devel mailing list