February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
How are these better than foo(/*width*/ 10, /*height*/ 20); ? One advantage of named parameter... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...said if you're passing around the width and height much (as opposed to just... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...better:
struct _(string s) { int data; alias data this; }
foo(_!"width"(10), _!"height"(20));
--
Simen | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...void foo(int width, int height); auto args = NamedParameterTypeTuple!(foo); args.width = 10; args.height... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...quite specific: "width :123" breaks an English rule for no purpose, and "width:123" is... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...no reason to write "width: 123" rather than "width:123" or "width : 123". Rather the... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...resize(Size size)
{
if (size.width)
this.width = size.width;
if (size.height)
this.height... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...void resize(int width=0, int height=0)
{
if (width)
// set new width
if (height... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...I could also do: int width = 10, height = 20; foo(width, height); The struct solution... | |||
February 28, 2011 General » Re: Pretty please: Named arguments | |||
|---|---|---|---|
| |||
...their own struct...
struct Width { int width; alias width this; }
foo(Width(10), Height(20)); | |||
Copyright © 1999-2021 by the D Language Foundation