Order of evaluation for named arguments
claptrap
clap at trap.com
Wed Apr 2 07:50:56 UTC 2025
On Wednesday, 2 April 2025 at 02:09:40 UTC, Steven Schveighoffer
wrote:
> 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.
Ok yeah thats a good point.
More information about the Digitalmars-d
mailing list