Order of evaluation for named arguments
claptrap
clap at trap.com
Mon Mar 31 23:16:57 UTC 2025
On Monday, 31 March 2025 at 21:43:07 UTC, Salih Dincer wrote:
> On Monday, 31 March 2025 at 19:47:01 UTC, Richard (Rikki)
> Andrew Cattermole wrote:
>>
>> It is my view that the order of evaluation should mirror that
>> of the programmer, or at least be predictable. Named arguments
>> entirely eliminate this predictability as a possibility as the
>> order of evaluation could change over time or be in any
>> position "unknown" to the user.
>
> +1
>
> If the probability is low, as Jonathan emphasizes, then please
> change the behavior of the D compiler. Or if not, in this case,
> here is the intermediate solution:
>
> **Add a warning or error message**
>
> "Named arguments are evaluated in parameter order, so be
> mindful of side effects!"
Or just require that parameters are always passed in the same
order as the declaration. Makes this bug impossible, and no
*silent* breakage.
More information about the Digitalmars-d
mailing list