[fpc-pascal] can the compiler zero any out parameter of procedure/function automatically?

vfclists . vfclists at gmail.com
Tue Jul 12 18:34:47 CEST 2016


On 11 July 2016 at 18:35, Dennis Poon <dennis at avidsoft.com.hk> wrote:

>
>
> Jonas Maebe wrote:
>
>> Dennis wrote:
>>
>>> I know it is my responsibility to initialize out parameters, but I think
>>> the compiler could help us by initializing all out parameters.
>>>
>> The compiler will fill out-parameters with garbage if you use the -gt
>> command line parameter, which can help you detect such problems more
>> easily.
>>
>> If you forget to assign a value to an out-parameter in a particular
>> case, having it return nil by default could easily be just as wrong as
>> it returning any other random value. For that reason, there is no
>> support for automatically initialising out-parameters.
>>
>> How about issue a compiler warning if one forgets to zero any out
> parameter?
>
> Dennis
>
>
The compiler might warn you about it, but it shouldn't initialize them out
for you.

Computers/compilers derive their power from being idiot savants and it is
wrong to make them anything other than that.

The compiler is supposed to implement what you say in the code, not what
you mean. You are the one who has the responsibility of expressing the
required states in as much detail as is possible.

-- 
Frank Church

=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160712/79101092/attachment.html>


More information about the fpc-pascal mailing list