Named Arguments Status Update - Overloading by name
jmh530
john.michael.hall at gmail.com
Wed Apr 10 12:00:42 UTC 2024
On Tuesday, 9 April 2024 at 21:33:21 UTC, Lance Bachmeier wrote:
> On Tuesday, 9 April 2024 at 21:15:59 UTC, Uranuz wrote:
>
>> I was thinking that assignment could be the reason, because
>> assigment could have some return value.
>
> Not just that, but also the way you can write function calls as
> assignments, even when you wouldn't expect it. A very nice
> feature when you have a use for it, but it also lets rebels
> write stuff like this:
>
> ```
> import std;
>
> void main() {
> writeln(f=4.7);
> auto h=g(f=4.7);
> writeln(h);
> }
>
> double f(double x) {
> return 2.5*x;
> }
>
> double g(double x) {
> return 2.5*x;
> }
> ```
That's a new one for me! Not sure I would want to make a habit of
that though!
More information about the Digitalmars-d
mailing list