DIP 1019--Named Arguments Lite--Final Review

Ethan gooberman at gmail.com
Mon Aug 26 22:18:51 UTC 2019


On Monday, 26 August 2019 at 21:48:42 UTC, Jonathan M Davis wrote:
> I know that some folks like Flag, but in general, I think that 
> it's an unnecessary complication.

I'm all about information at a glance. The more you are able to 
understand a line of code without looking at the surrounding 
lines, the clearer and easier to maintain that code is.

Simple example:

void DoSomething( bool Multithreaded, bool Logging );

Which, when invoked using literals, looks like:

DoSomething( true, false );

Yech. That's where flags comes in handy:

DoSomething( Multithreaded.Yes, Logging.No );

Bam. Far more readable at a glance. Named parameters remove the 
template instantiations from that example:

DoSomething( Multithreaded : true, Logging : false );

At the cost of needing to do a "find and replace in files" when 
upgrading compilers/libraries if a parameter name changes, in 
both cases you have far more readable code.

Besides. Didn't the DIP here include a mechanism for handling 
parameter renaming and forwarding? And marking parameter name 
sets as deprecated?


More information about the Digitalmars-d mailing list