Deutsch English Français Italiano |
<20240410174139.914@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: Recursion, Yo Date: Thu, 11 Apr 2024 00:54:41 -0000 (UTC) Organization: A noiseless patient Spider Lines: 62 Message-ID: <20240410174139.914@kylheku.com> References: <uut24f$2icpb$1@dont-email.me> <uutqd2$bhl0$1@i2pn2.org> <uv2u2a$41j5$1@dont-email.me> <87edbestmg.fsf@bsb.me.uk> <uv4r9e$mdd3$1@dont-email.me> <uv5e3l$q885$1@dont-email.me> <uv5gfd$qum1$1@dont-email.me> <uv5lgl$s6uj$1@dont-email.me> <uv61f6$v1jm$1@dont-email.me> <uv68ok$11080$1@dont-email.me> <uv7a8n$18qf8$3@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 11 Apr 2024 02:54:41 +0200 (CEST) Injection-Info: dont-email.me; posting-host="0cee97af41ea72e01665d97a873fd1de"; logging-data="1370143"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vVc6Vrrsxb0AcCnjgTHnKG0ZElJVZ/Bw=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:6eF0mYhLTY+jM2516IGMS3XVx9s= Bytes: 3386 On 2024-04-11, Lawrence D'Oliveiro <ldo@nz.invalid> wrote: > On Wed, 10 Apr 2024 16:46:43 +0200, David Brown wrote: > >> Just for your entertainment, with C++ lambdas this is now legal code: >> >> void foo(void) { >> [](){}(); >> } > > C programmer still has habit of writing “(void)” when C++ allows “()” > instead. That is backwards. (void) is the dud that C++ "allows"; () is the "native" empty parameter list in C++, and has been from the early beginning. C++ (originally C With Classes) introduced () as a prototyped, declared parameter list. At that time there was no (void) in C, and therefore not in C++ either. In C, the () list, in a declaration, didn't say anything about the number of parameters. ANSI C came along and invented (void) in order not to change the meaning of () for compatibility. Then C++ adopted (void) for ANSI C compatibility. I.e. (void) is concession that that C++ "allows", and did not always; () is the "native" empty parameter list it always had. It's monumentally stupid when you see (void) on feature that only exists in C++ and therefore C compatibility is not involved: myclass::myclass(void) { // default constructor } > Does the latest C spec now also take “()” to mean “no args” (synonymous > with “(void)”) instead of “unspecified args”? The N3320 working draft says: "The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters." (6.7.7.4 Function declarators) "For a function declarator without a parameter type list: the effect is as if it were declared with a parameter type list consisting of the keyword void. A function declarator provides a prototype for the function." (ibid.) The last sentence assures us that function declartions are now protypes; there are no function declarators that do not prototype the parameters. (Apologies to Kenny for the "ibid.") -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca