Sujet : Re: Threads across programming languages
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.c++ comp.lang.cDate : 05. May 2024, 11:37:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240505123718.00000503@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
On Sun, 5 May 2024 01:41:49 -0000 (UTC)
Lawrence D'Oliveiro <
ldo@nz.invalid> wrote:
On Sat, 4 May 2024 20:41:42 +0300, Paavo Helde wrote:
On 04.05.2024 01:20, Lawrence D'Oliveiro wrote:
On Fri, 3 May 2024 18:01:02 +0300, Michael S wrote:
For C, I agree, mostly because C has no nested functions.
GCC implements nested functions in the C compiler. Though oddly,
not in C++.
C++ already has functions nested in namespaces, namespaces nested in
namespaces, functions nested in classes (static and non-static
member functions), and classes nested in classes. It's already a
lot of nesting, no need to complicate the matters more.
In Pascal, function nesting is used for better encapsulation of
data. In C++, the same is achieved in a cleaner and more explicit
way via classes and member functions, so no need for this kind of
nesting.
Interesting, isn’t it? You mention all the complications of C++, and
how it doesn’t need yet more complications tacked on top to support
something as simple as lexical binding. Yet Pascal had lexical
binding from the get- go, and managed it in a much simpler way.
Pascal pays huge price for its simplicity in terms of lack of locality.
That is, the price is paid by users of Pascal, rather than by language
itself.
There are many other languages that have both nested functions and
locality (i.e. allow declaration of variable at block or scope), but I
find understanding of code written in this languages (my experience is
mostly with Ada) way too hard.
As a code reader, I very much prefer C, where nested function are not
allowed at all. May be, I would like BCPL, where nested functions are
allowed, but have no access to variables defined at outer scope, even
better than C, but I never had an opportunity to use BCPL.
Classic C++, where you can fake BCPL-style nested functions by static
member functions of locally-defined classes is not bad,
functionality-wise, but as is often a case with Classic C++, is ugly
syntactically.
Modern C++, with lambdas and captures, has the same or worse readability
and comprehensibility problems that I disliked in the past with Ada.