DIP 1019--Named Arguments Lite--Final Review
a11e99z
black80 at bk.ru
Sat Aug 24 11:33:37 UTC 2019
On Saturday, 24 August 2019 at 06:17:07 UTC, Walter Bright wrote:
> On 8/23/2019 10:00 PM, a11e99z wrote:
>> so which one should be called in sample below?
>>
>> import std.stdio;
>> void foo(int a, int b) {writeln("0");}
>> void foo(int b, double a) {writeln("1");}
>> void main()
>> {
>> foo(b: 10, 0);
>> }
>
> According to my suggestion, "1" is unambiguously selected.
>
> https://digitalmars.com/d/archives/digitalmars/D/DIP_1019--Named_Arguments_Lite--Community_Review_Round_2_327714.html#N327755
when I look at snoopy(..) code, only one name comes to mind
"quantum entanglement".
some definitions (and sorry for my English):
defaulted args=args that has default values
non-defaulted/positional args=args that has not default values
and they should be assigned by user
named args=args with names. opposite to them=unnamed args.
ask yourself: why usual programmers needs named args?
my assumption:
- skip some args with default values
u have list of defaulted values, most of them suit u, and some
u want to change.
- and user remember arg name but don't remember it position.
lets say this 2 points cover 90% of use cases
- u remember position of arg with it meaning, but don't remember
it name, and u don't remember meanings of args before the one
probably u will assign values to "before" args by name. well, u
remember name of it but not meaning. ok.
- something more weird here...
last 10%
so, to make happy 90% of user that wants named args u can just
add to lang:
named args follows by unnamed args (not vice versa, no mixing)
- it simple to add it to compiler
positional goes first (order is matter), named goes after
(order doesn't matter)
ensure that all non-defaulted args are set by pos or by name.
ensure that no args set more than once.
- it simple to understand, no need to know quasiparticles of
compiler.
10% other users should to see func definition and fill args in
right order or with right names.
it is fair.
other users should understand their code too if they(others) want
(for learning) or should (review/pr).
your snoopy sample is mind killer and just mess.
and reality will be more horrendous.
u will not write such code yourself, so why u gives to others gun
to shoot not only their legs but others heads?
in snoopy-case I see next:
- need to add __traits( snoopy(s:s, i, t:t)) that returns full
function description that will be called by compiler for such
code.
- probably overloads will become dangerous pond of D programming.
- most of us will don't understand such named code without help
from IDE. bye simple text editors.
- new WTF Waves at forum messages, more questions about details
of naming.
- remember about DPP when will be added to D sea of overloads C++
functions.
last one:
named args should be done for (most of) users, not for
researching D-dark-deeps by gods or quantum nerds.
u have deal in compiler with people not with bytes.
and return back to question "why usual programmers needs named
args?"
why no complains from C# programmers about
pet/toy/too_constrained named args?
I think cuz it enough for everything/everybody and behind that
line lives dragons.
More information about the Digitalmars-d
mailing list