Named Arguments Status Update - Overloading by name
Markelov69
markmarchenko79 at gmail.com
Fri Apr 19 07:18:57 UTC 2024
On Wednesday, 10 April 2024 at 13:47:19 UTC, bachmeier wrote:
> On Wednesday, 10 April 2024 at 12:18:06 UTC, jmh530 wrote:
>
>> That line with `auto h` can also be written `auto h = g = f =
>> 4.7;` and you get the same result.
>>
>> Learn something new every day, I guess. The function spec [1]
>> doesn't talk about this, but it must be something with an
>> assign expression [2] of f = a getting re-written to f(a) for
>> functions.
>>
>> [1] https://dlang.org/spec/function.html
[2] https://plnkgame.com
>> [3] https://dlang.org/spec/expression.html#assign_expressions
>
> I learned about it from the properties chapter in Ali's book:
> http://ddili.org/ders/d.en/property.html
>
> It's particularly useful for clean interfaces when you're
> wrapping structs allocated by a C library. You may have to do
> various operations behind the scenes, like converting D strings
> to their C counterparts so the data can be used internally, but
> you still want to be able to work with it in the natural way
> `x.names = ["blue", "green", "red"]`.
Thank you!
More information about the Digitalmars-d
mailing list