Order of evaluation for named arguments
Daniel N
no at public.email
Sun Mar 30 09:14:49 UTC 2025
On Saturday, 29 March 2025 at 18:38:31 UTC, Steven Schveighoffer
wrote:
> In the D spec, the function parameter [section on order of
> evaluation](https://dlang.org/spec/expression.html#order-calls)
> says:
>
>> Arguments are evaluated left to right.
>
> So a question was raised, what about named arguments, since
> those might not match the order of parameters?
>
I think you are overlooking one important detail,
StructInitializer, it must match named arguments and fortunately
it does.
```d
import std.stdio;
struct S { int a, b; }
int fun(int v)
{
v.writeln;
return v;
}
void main()
{
S r;
S s = { b:fun(1), a:fun(2) };
}
```
2
1
More information about the Digitalmars-d
mailing list