Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c Subject: Re: Recursion, Yo Date: Thu, 11 Apr 2024 20:47:48 +0200 Organization: A noiseless patient Spider Lines: 63 Message-ID: References: <87edbestmg.fsf@bsb.me.uk> <_zSRN.161297$m4d.144795@fx43.iad> <20240411075825.30@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 11 Apr 2024 20:47:49 +0200 (CEST) Injection-Info: dont-email.me; posting-host="90e30c6ef7bcafc98b4a35b314c59c84"; logging-data="1945533"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1915ivNILIY7jHTf8Xc9/ukwl8tv1cyxpE=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:1UrdNdImEPD+RPr031yLD20QhYc= Content-Language: en-GB In-Reply-To: <20240411075825.30@kylheku.com> Bytes: 3746 On 11/04/2024 17:04, Kaz Kylheku wrote: > On 2024-04-11, Scott Lurndal wrote: >> David Brown writes: >>> On 11/04/2024 02:18, Lawrence D'Oliveiro 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. >>> >>> I do that sometimes, yes. I could argue that I think it is better to be >>> explicit than implicit, but it's just my fingers on automatic. >> >> I would use the same argument. Make it explicit. > > (void) is a dongle intoduced in ANSI C so that () could continue > to mean "unknown number of parameters". It didn't exist in C++ > until ANSI C invented it. I like history as much as the next person - probably more so, and thus I do appreciate you explaining where this comes from. But I don't base my programming choices or style on history. From the point of view of current programming, it's irrelevant when "(void)" was introduced to C and C++, it's only relevant what it means /now/ to the compiler, and what it means to someone reading the code. I write "(void)" in C code, or in C++ code that might be seen by a C compiler (such as in a header file that could be used with C or C++), or if it might be read by someone who is more familiar with C than C++. If the code is "pure C++", such as this example, I normally don't bother with "(void)". But I don't object to it either. > > () is a perfectly explicit empty list. (void) does not look empty; > it looks like it's declaring one parameter of type void. "void" has always been a bit weird as a "type" or as a placeholder for an empty type. > > An actual implicit empty parameter list might look like this: > > function foo > { > } > > Once you have empty parentheses, that is explicit. > "(void)" stands out more. > Countless programming languages have only (); no such thing as (void) or > similar ugly hack, due to not having a quirky history that would have > caused such a thing to be required. > It has never struck me as "ugly", but it is arguably quirky.