Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #101054
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Poor-man's named parameters with compound literals and designated initializers |
| Date | 2017-01-03 15:06 -0800 |
| Organization | None to speak of |
| Message-ID | <lnk2abu4j2.fsf@kst-u.example.com> (permalink) |
| References | <5a44ef82-defa-4766-8c1f-c280d5855f2c@googlegroups.com> <o4h9u3$guu$1@dont-email.me> |
BartC <bc@freeuk.com> writes:
> On 03/01/2017 20:43, luser droog wrote:
>>
>> int
>> myfunc( struct args ){
>> ...
>> }
>>
>> struct args {
>> int par1;
>> int par2;
>> };
>>
>> ...
>>
>> (void)myfunc( (struct args){ .par1 = 42, .par2 = 7 } );
>
> You need Thiago Adam's struct member defaults to go with it.
They're not absolutely needed. Any omitted members default to zero.
You can often (but not always) arrange for that to be a meaningful
default value.
> (This might tick a box but it's generally unwieldy compared to the real
> thing. However, when they added designated initialisers, they could have
> introduced named parameters at the same time.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
Poor-man's named parameters with compound literals and designated initializers luser droog <luser.droog@gmail.com> - 2017-01-03 12:43 -0800
Re: Poor-man's named parameters with compound literals and designated initializers BartC <bc@freeuk.com> - 2017-01-03 22:53 +0000
Re: Poor-man's named parameters with compound literals and designated initializers Keith Thompson <kst-u@mib.org> - 2017-01-03 15:06 -0800
csiph-web