C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] Designated initializers in C++ and C

From: Niall Douglas <s_sourceforge_at_[hidden]>
Date: Fri, 14 Aug 2020 11:48:35 +0100
On 14/08/2020 07:15, Uecker, Martin wrote:

> Quite frankly, I also do not see many C++ features (or other
> features) which i think should be added to C.

My top three of existing [1] C++ features:

1. C++ lambdas.

2. Auto-syntax generics, as there are occasions where a macro really
isn't suitable (and if you adopt C++ lambdas, then you have adopted auto
syntax generics in any case).

3. Coroutines, but with a C API (I have an ulterior motive here: I'd
like the C formulation of Coroutines to become v2 of the C++ Coroutines
API). In case some on WG14 find these scary sounding, they're actually
just a Duff's device, just minus the complex and error prone
switch...case logic (there is on github a very good C++ Coroutines
emulation written entirely in the C preprocessor!).

[1]: If from non-existing C++, I really would like C to gain Reflection,
but with a C API. This would be very widely useful to all C speaking
languages.

> C is mostly fine as it is, we should try to polish the
> rough edges, make the specification clearer, work on
> a sound (and formalizable) memory model, etc.

My top three things sorely needing standardising in C, and hence for all
other programming languages which can speak C:

1. Modern failure handling (cf. mine and Jens' paper implementing Herb's
exceptions in C, it also tackles the errno problem, signal handling etc etc)

2. Shared libraries, and specifically the visibility and bundling of
symbols and collections and layers thereof. MUST have a standard
compile-time and run-time interrogation API which can be custom extended
by other programming languages e.g. C++ can specify classes, Modules, etc.

3. A modern link layer, as a table of ASCII strings might suit C just
fine, but it's painful (slow, hard to customise e.g. mangling, scales
poorly) for C speaking languages. My suggestion: lift just enough from
C++ Modules, specifically Gabriel dos Reis' work on this, for a modern,
standard, link layer which suits most C speaking languages.


You can probably spot a theme here: C's weakest area, in my opinion, is
as a lingua franca between C speaking languages. If it could improve
itself on lingua franca, that would have outsize network effects and
benefits across all computer software. A lot of that would do much good
for C++, as well.

Niall

Received on 2020-08-14 05:52:01