Hello Johannes, W dniu 01.09.2016 o 15:56, Johannes Schindelin pisze: > On Thu, 1 Sep 2016, Jakub Narębski wrote: >> It's a pity that emulation of named parameters in C requires >> relying on designated inits from C99 >> >> typedef struct { >> double pressure, moles, temp; >> } ideal_struct; >> >> #define ideal_pressure(...) ideal_pressure_base((ideal_struct){.pressure=1, \ >> .moles=1, .temp=273.15, __VA_ARGS__}) >> >> double ideal_pressure_base(ideal_struct in) >> { >> return 8.314 * in.moles*in.temp/in.pressure; >> } >> >> ... ideal_pressure(.moles=2, .temp=373.15) ... Forgot to add citation: [1] Ben Klemens "21st Century C: C Tips from the New School", 2nd Ed. (2014), O'Reilly Media, chapter 10. "Better Structures", subsection "Optional and Named Arguments" > > Yeah, that looks unwieldy ;-) > Declaration needs some trickery, but use is much, much more readable (if we cannot use sensibly named variables for passing arguments): ideal_pressure() ideal_pressure(.temp=373.15) ideal_pressure(.moles=2) ideal_pressure(.moles=2, .temp=373.15) It is even better if there are large amount of parameters: res = amortization(.amount=200000, .inflation=3, .show_table=0, .extra_payoff=100) vs double amortize(double amt, double rate, double inflation, int months, int selloff_month, double extra_payoff, int verbose, double *interest_pv, double *duration, double *monthly_payment); But we can't use it in Git, anyway -- Jakub Narębski