🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2005

Re: C and its peasant 'ancestors'

#2005
From: David Brown
Date: Mon, 30 Nov 2026 08:34
64 lines
4614 bytes
On 28/11/2026 19:12, bartc wrote:
> On 28/11/2026 16:31, Bonita Montero wrote:
>> Am 28.11.2026 um 16:28 schrieb bartc:
>>
>>> Yet every example of C++ you've ever posted is always an unreadable, 
>>> ugly mess of syntax.
>>
>> A very disordered opinion.
>>
>>> Not all that is the fault of the language - you seem to delight in 
>>> using every obscure feature possible and have nested functions 
>>> everywhere.
>>
>> C++-developers understand my code since they're more skilled like you.
> 
> It's not a skills issue. The language as used like this is several times 
> more complex than is needed.
> 
> 
>>> Below is a recent post of yours about sorting in C++. It took me a 
>>> while to realise it was actually testing two kinds of sort!
>>
>> I don't know why this should be hard to understand.
>> Maybe it's beyond your capabilities.
> 
> Because it's a ******* mess. Here's a function you created simply for 
> copying one array to another:
> 
>     auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() ); 
> dummy += srt[0]; };
> 
As a small point here - local lambdas like this are sometimes very handy 
in C++ to reduce duplication of code.  If you find yourself repeating 
roughly the same bit of code a number of times within one function, 
there are several ways to handle it.

Copy-and-paste is the obvious one, and sometimes this simple solution is 
the best - it's clear what you are doing, but any changes you make later 
must be copied-and-pasted too.

You can extract the code to an external "static inline" function, but 
that might mean passing a lot of local variables as parameters, and if 
you want "pass by reference" in C, that means going via pointers.  The 
resulting code will be efficient when the compiler inlines it, but it 
can be messy.

You can extract the code to an external macro.  That saves you from 
passing all the local variables, but macros have no scope, and 
multi-line macros are messy.

You can use the gcc local function extension, but that is not portable.

In C++, you can use lambdas.  For such usage, it is just a way of making 
a local function with convenient access to other local variables, and it 
will be complied like local inline code.

There is a serious proposal to add lambdas to C, but the design still 
has issues before it can make it to the standard.


(This lambda is completely unnecessary in Bonita's code - that code 
should have used std::array<> types rather than std::vector<> types, and 
the copy would have been done as "srt = origin;".)
Technical Details
Message-ID: <11ejce7$8eck$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11dup6q$v4j9$1@dont-email.me> <11e0kde$1jpvu$1@dont-email.me> <11e0r13$1lqm6$1@dont-email.me> <11e0uc0$1mtpv$1@raubtier-asyl.eternal-september.org> <11e7fj4$37l9$1@dont-email.me> <11e8oro$ft4l$1@raubtier-asyl.eternal-september.org> <11e8stp$hajr$1@dont-email.me> <11e8ti0$hhqa$1@dont-email.me> <11e8v24$i2mc$2@raubtier-asyl.eternal-september.org> <11e9045$ihk3$1@dont-email.me> <11e90a8$ikh0$1@dont-email.me> <11e90mv$io87$2@raubtier-asyl.eternal-september.org> <11e91ns$j5dv$1@dont-email.me> <11e92ff$jclo$1@raubtier-asyl.eternal-september.org> <11e95j2$kimu$1@dont-email.me> <11e96aa$kpta$1@raubtier-asyl.eternal-september.org> <11ect54$20qpr$3@dont-email.me> <11edmpn$2938p$1@raubtier-asyl.eternal-september.org> <11eerur$2me3k$1@dont-email.me> <11eevkk$2nu8b$1@raubtier-asyl.eternal-september.org> <11ef5ik$2q9c9$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: C and its peasant 'ancestors'
Date: Mon, 30 Nov 2026 09:34:15 +0100
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <11ejce7$8eck$1@dont-email.me>
References: <11dup6q$v4j9$1@dont-email.me> <11e0kde$1jpvu$1@dont-email.me>
 <11e0r13$1lqm6$1@dont-email.me>
 <11e0uc0$1mtpv$1@raubtier-asyl.eternal-september.org>
 <11e7fj4$37l9$1@dont-email.me>
 <11e8oro$ft4l$1@raubtier-asyl.eternal-september.org>
 <11e8stp$hajr$1@dont-email.me> <11e8ti0$hhqa$1@dont-email.me>
 <11e8v24$i2mc$2@raubtier-asyl.eternal-september.org>
 <11e9045$ihk3$1@dont-email.me> <11e90a8$ikh0$1@dont-email.me>
 <11e90mv$io87$2@raubtier-asyl.eternal-september.org>
 <11e91ns$j5dv$1@dont-email.me>
 <11e92ff$jclo$1@raubtier-asyl.eternal-september.org>
 <11e95j2$kimu$1@dont-email.me>
 <11e96aa$kpta$1@raubtier-asyl.eternal-september.org>
 <11ect54$20qpr$3@dont-email.me>
 <11edmpn$2938p$1@raubtier-asyl.eternal-september.org>
 <11eerur$2me3k$1@dont-email.me>
 <11eevkk$2nu8b$1@raubtier-asyl.eternal-september.org>
 <11ef5ik$2q9c9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 30 Nov 2026 08:34:16 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="276884"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18wHU7Hv05Ikcyy+v4QB1ODwVpgFr4CmiI="; posting-host="a448ec79be8238d2c3ca54b79fa3e2af"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hRXX7vsrRGOO1RZ9QI8StYqqsmk= sha256:6N+UNRccETHfMSxE8R/o7JEU5b2I0zQsvg3LHau9YoA=
	sha1:GKwnzjvS2FnIPGe9qD7K8clkMs0= sha256:PRJ35CteQtuw2U7lbur2WL/WB9IGg/8oWdtX2wI9BiY=
In-Reply-To: <11ef5ik$2q9c9$1@dont-email.me>
Content-Language: en-GB, nb-NO