Sujet : Re: Named arguments in C
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 04. Jul 2024, 03:50:04
Autres entêtes
Organisation : None to speak of
Message-ID : <875xtlx44j.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
[...]
It really needs language support. That has been done in C for
designated initialisers; named args are a similar feature, easier to
implement (they can only be one level deep for example) and IMO far
more useful.
>
Although there are a few extra problems with C because the extra info
needed (parameter names and default values) can appear in both the
definition, and any number of prototype declarations, which cannot in
conflict.
As I recall, we had this discussion here a while ago. The fact that C
allows parameter names for a function definition to differ from those in
corresponding declarations is a bit inconvenient. But what I recall
suggesting at the time is that the parameter names in a call need to be
consistent with the names in the visible declaration.
void foo(int x, int y) {
// ...
}
void foo(int xx, int yy);
foo(xx: 10, yy: 20);
See Message-ID <
87pm36byty.fsf@nosuchdomain.example.com>, posted last
August.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */