[fpc-pascal] Managed record questions

Sven Barth pascaldragon at googlemail.com
Thu Mar 8 14:28:32 CET 2018


Am 08.03.2018 12:51 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:



> On Mar 8, 2018, at 5:42 PM, Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:
>
> You are supposed to use try...finally for this. The finally-block is
always executed when the try-block is left no matter if it's by reaching
the end, calling exit or by an exception.
>

But my greater point is why are we doing any of this at all? Try blocks,
ARC, management operators, garbage collectors, all because we can’t
allocate on the stack. I understand there are objects (which are missing
how many features that classes have?) and records which lack a fundamental
OOP feature which is inheritance.

The stack knows when the scope is terminated so it could easily free these
classes for us and all too often we only need an object for the duration of
a single function so allocating dynamic memory is just wasteful. I know
there’s not much we can do about it now but it’s a really unfortunate
oversight.


This is not an oversight, but an explicit design decision of the language.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180308/b2e113b5/attachment.html>


More information about the fpc-pascal mailing list