Re: [dev] Suckless remote shell?

From: Szabolcs Nagy <>
Date: Thu, 7 Nov 2013 03:37:05 +0100

* Alexander S. <> [2013-11-07 04:27:26 +0400]:
> Seriously, simple parametric types wouldn't hurt C. Not at all. No
> need for that automatic pointer conversion, additional parameters to
> sort() and alike, and such. (I'm going to make a confession, I really
> think C would benefit from C++ templates, even in their current
> state).

c has no implicit pointer conversion other than for void*

void* is important to represent pointers in a generic way,
parametric types do not help with this, those assume a
statically known type which is not always the case

the way c++ eliminated the implicit conversion is actually
less safe than the c semantics: in c++ one has to use casts
to convert void* and this turns off the type-checker

there are plenty source for void pointers: mmap, dlsym,
context pointers for callbacks, etc. if you incorrectly
assume in c that a pointer is void* then you get a type error,
in c++ your cast will mask this error so it can go unnoticed,
in c a cast is a code smell that alarms you, in c++ they are
not uncommon at all in code interacting with the os, actually
c++ has at least 4 different casts with different semantics
based on what you cast, this is not how to improve safety

parametric types have problems on their own: eg the type
parameters have to be encoded into the name of the interface
which gives rise to name mangling with all its warts
(c++ name mangling is not specified so you get a fragile binary
interface with names so long that the hash lookups by the elf
dynamic loader becomes a bottleneck..)
Received on Thu Nov 07 2013 - 03:37:05 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 07 2013 - 03:48:06 CET