DIP 1019--Named Arguments Lite--Final Review

a11e99z black80 at bk.ru
Sat Aug 24 08:31:17 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".

ask yourself: why need named args for usual programmers?
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.
- 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.
another 10%

so, to make happy 90% of desirous user for named args u can just 
add to lang:
named args follows by positional args (not vice versa, no mixing)
well:
- it simple to add it to compiler
   args after positionals have prefix "name:" that should be 
assigned to right var
   and check that all non-defaulted args are set.
   and check that no args set more than once.
- it simple to understand it, 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 
want(learning) or should(review).

in snoopy-case I see next:
- need to add __traits( snoopy(s:s, t:t, i)) that returns full 
function description that will be called by compiler.
- probably overloads will become dangerous points of D 
programming.
- new WTF Waves at forum messages.
- 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.


More information about the Digitalmars-d mailing list