Order of evaluation for named arguments

claptrap clap at trap.com
Tue Apr 1 11:26:34 UTC 2025


On Tuesday, 1 April 2025 at 02:04:44 UTC, monkyyy wrote:
> On Monday, 31 March 2025 at 23:16:57 UTC, claptrap wrote:
>> 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:
>>>> [...]
>>>
>>> +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.
>
> Doesnt that make the whole thing meaningless

I thought the point was to document at call site, ie clarify long 
parameter lists, and enable skipping defaults?

I mean I don't see the point of just being able to change the 
order the parameters are passed in?


More information about the Digitalmars-d mailing list