"headconst" dynamic arrays?
Marco Leise
Marco.Leise at gmx.de
Wed Aug 31 12:22:41 PDT 2011
Am 31.08.2011, 20:27 Uhr, schrieb Kagamin <spam at here.lot>:
> bearophile Wrote:
>
>> Some functions need to do everything on a given array, while in other
>> functions I just want to change the array contents. How can the source
>> analyzer tell them apart and show some warnings only on the second kind
>> of functions, without specific annotations?
>
> It will check them indiscriminately. There's little need to overwrite
> input parameters. Input parameters are by nature likely to be read,
> overwriting them usually means you lose them, and losing parameters that
> are likely to be read is a bad practice, so it's a good idea to check
> for it.
I had some of these cases in my JavaScript code where I process the
parameter before I use it. But I'm now listening to Eclipse's advice and
give them proper variables. So zoom becomes effectiveZoom and so on. But I
guess it is a matter of preference. It is like Delphi's "Result" variable
in functions that you can write to several times until you have your final
output. Likewise people sometimes modify the input until they've got what
they want. Clamping numbers, prefixing strings or replacing default/null
values are use cases.
More information about the Digitalmars-d
mailing list