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

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Feb 10 18:51:38 UTC 2020


On Mon, Feb 10, 2020 at 01:39:12PM -0500, Steven Schveighoffer via Digitalmars-d wrote:
> 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!
[...]

And there you have it, we already have named parameters. :-P  Albeit in
a verbose, circumlocutious way. :-P


T

-- 
English has the lovely word "defenestrate", meaning "to execute by throwing someone out a window", or more recently "to remove Windows from a computer and replace it with something useful". :-) -- John Cowan


More information about the Digitalmars-d mailing list