[fpc-pascal] SetLength warnings - request
Michael Van Canneyt
michael at freepascal.org
Mon Dec 31 10:22:33 CET 2018
On Mon, 31 Dec 2018, Martok wrote:
>> 1) Dynamic arrays are initialised with nil, but that is an
>> implementation detail
> Is it, though? Global variables and instance fields are zero-filled, local
> variables as if the local variable block was a record passed to Initialize()
> (so, recursively zeroing managed fields). Although it is never spelled out, the
> Delphi manual heavily implies this.
> I would guess most if not all pascal programmers wrote code that relies on that
> at some point.
And they are all wrong in doing so. It's like spelling:
It's not because 99% of the population makes a mistake that it automagically becomes correct.
We can decide to adapt the (spelling) rules, but till that decision is made
explicit, 99% of the population is actually making a mistake.
For native english speakers the above may be somewhat farfetched: But in Dutch
and French, spelling and grammar are not ruled by custom, but are strictly managed
by official language committees...
> @MvC: I'll come up with some examples and add it to the Portability page, since
> the different result variable initialization rules already are a bit of an issue.
I'm curious to see them, because all 'issues' reported here can be perfectly
repeated (possibly with some modifications) in Delphi.
The non-initialization of 'Result' has bitten me more than once in Delphi.
I can't explain things better than Jonas did. I intend to rework his
arguments and introduce them in the language reference manual.
More information about the fpc-pascal