DIP 1030--Named Arguments--Community Review Round 1 Discussion

Steven Schveighoffer schveiguy at gmail.com
Mon Feb 10 18:39:12 UTC 2020


On 2/10/20 1:36 PM, H. S. Teoh wrote:
> On Mon, Feb 10, 2020 at 01:27:49PM -0500, Steven Schveighoffer via Digitalmars-d wrote:
>> On 2/6/20 10:33 PM, Jonathan M Davis wrote:
>>> Once in a while, named arguments may be useful, but for the most
>>> part, they're useful because a function has way too many parameters,
>>> in which case, the function should have been designed differently.
>>
>> I find this assertion lacking evidence.
>>
>> How does one design a constructor that initializes all the fields of a
>> type without including all the parameters to initialize that type?
> [...]
> 
> Ostensibly, by encapsulating the parameters into a struct and passing
> said struct up the ctor chain. ;-)

So basically, for each type you need to define another type to pass 
parameters? Sounds... excessive ;)

And the benefit of having a POD struct to pass as a parameter to cut 
down on constructor parameters is... you get named parameters!

-Steve


More information about the Digitalmars-d mailing list