DIP 1019--Named Arguments Lite--Final Review

Ethan gooberman at gmail.com
Tue Aug 27 21:52:50 UTC 2019


On Monday, 26 August 2019 at 23:36:22 UTC, Jonathan M Davis wrote:
> That particular use of Flag is more valuable than many uses of 
> it, because you actually have multiple arguments

It's exactly as valuable as single arguments. For example:

DoSomething( Multithreaded.Yes );

DoSomething( Mutlithreaded : true );

Versus:

DoSomething( true );

Or even worse:

enum bool IsMultithreaded = true;
DoSomething( IsMultithreaded );

(Two lines of code need to be understood for a single function 
call; and there's no guarantee that the IsMultithreaded parameter 
is defined next to the call site. For anyone choosing to single 
that one out, there's your answers.)

Did you know it's a coding standard at Insomniac - creators of 
Ratchet and Clank and the recent Spiderman game - to not use 
boolean arguments and instead create one of those yes/no enums?

I've already stated that named arguments as a language feature 
are not a method of enforcing programming standards on people. 
How you choose to approach the above problem is up to the 
programmer. If they want to aim for readable like my examples, 
great. If they want to aim for obtuse interfaces that requires 
understanding pages of documentation, well, that's up to them too.

Certainly, all this talk about documentation falls within the 
"programming standards" point I raise.


More information about the Digitalmars-d mailing list