Order of evaluation for named arguments
Steven Schveighoffer
schveiguy at gmail.com
Wed Apr 2 02:09:40 UTC 2025
On Tuesday, 1 April 2025 at 11:26:34 UTC, claptrap wrote:
> I mean I don't see the point of just being able to change the
> order the parameters are passed in?
```d
int generateNextThing(); // assume this is not easy to replicate
void foo(int a, int b);
void main() {
// I want to pass the next thing in as b, and the next next
thing in as a.
auto bval = generateNextThing();
foo(generateNextThing(), bval);
// hey, why not just pass them in the order specified!
foo(b: generateNextThing(), a: generateNextThing()); // oops
next thing goes to a, next next thing goes to b.
}
```
It's not exactly a killer example, but you can see how one might
expect that to work as the spec details.
-Steve
More information about the Digitalmars-d
mailing list