DIP 1019--Named Arguments Lite--Community Review Round 1
JN
666total at wp.pl
Sun Feb 17 19:52:14 UTC 2019
On Sunday, 17 February 2019 at 18:57:26 UTC, 12345swordy wrote:
> Regardless, my objections still stand regarding @named
> attribute and I can not tell other people with a straight face
> that in order to use named parameters they have to use @named
> attribute without expecting them to look at me like "Are you
> insane?"
>
> I do not want D design to be worst, because of the "avoiding
> breaking code at all cost" mentality. That is what C++ is for.
While I still think @named attribute feels weird, I know at least
one language that requires opt-in for named arguments: Dart. An
example is here: https://stackoverflow.com/a/13264231 . In Dart,
you can mark arguments as named:
getHttpUrl(String server, String path, {int port: 80})
and then call it:
getHttpUrl('example.com', '/index.html', port: 8080);
and you MUST use the name if it's a named argument.
Also, mixing optional arguments and named arguments is just not
allowed, so it solves the issue of how to deal with such
ambiguous cases:
thisFunctionWontWork(String foo, [String positonal], {String
named})
More information about the Digitalmars-d
mailing list