Chris Torek said:
On Fri, 31 Oct 2003 23:29:34 -0000, in comp.lang.c , "Peter Pichler"
["That which is topical in comp.lang.c"] is not really obvious
from the group's name.
Indeed, a short string of words and abbreviations (like "comp.lang.c"
or, to name two groups I do not read, "rec.arts.int-fiction" and
"soc.culture.magyar") is simply not *enough*.
Newsgroups should have posted charters. Having to divine the topic of
a newsgroup by reading tea leaves for a few weeks is a stupid idea.
The problem is never knowing when you've done it enough (1 week, 2
weeks, 6 months?). At least if there was a FAQ or charter you'd know
when you had enough information, and you'd never be in doubt. And
although I don't think "What's the topic of comp.lang.c?" is a very
frequently asked question, it certainly is a very frequently provided
answer! I think it's demonstrable that the extant information on the
topic is not sufficient, otherwise people wouldn't have to be told so
much.
In this particular case (asking about named parameters), I think it
can be topical on *both* groups. In comp.std.c one can ask whether
any future standard might include them, and whether there is any
existing work that can be referenced. In comp.lang.c one can ask
whether there is a way to at least "fake them" now -- and there is!
In particular, it is possible to obtain named parameters in C99.
You simply have to stop using ordinary function calls as if they
were ordinary function calls. Instead, pass your parameters as if
you were writing Mesa code: construct a "record" -- in C, called
a "struct" -- using the C99 "compound literal" syntax. Here is an
example function:
And that's where my wording got me. I have been thinking of using the
structure method, but I was hoping to hear if there was a better way,
but I didn't ask it correctly (ah, wonderful hindsight!). My thought
process was more along the lines of what you suggest, but I viewed it
as "adding it to C" because it's not part of the standard or any
implementation I know of.
Anyway, it's good to know that my method wasn't completely barking up
the wrong tree. It's still ugly (and maybe slow), but it's helpful
when you have several parameters all of the same type.