[TUHS] v7 K&R C

Steffen Nurpmeso steffen at sdaoden.eu
Sun Apr 26 06:27:06 AEST 2020


Noel Chiappa wrote in
<20200425194102.3A54318C0BE at mercury.lcs.mit.edu>:
 |> From: moanga
 |
 |>> To make chaining of calls simpler. Write
 |>>   f()->g()->h()->i()
 |
 |Ah; I was confused by his notation; I didn't realize he meant the C \
 |operator
 |'->'.

Oh, i love this method-on-object as opposed to object-on-function
methodology.

  while(_tr.read_line(*&_line) >= 0){
    ln = _line.trim().squeeze().data();
    len = _line.length();

which can easily exceed a 80x2[45] screen in C.  Especially with
"more modern" frameworks which try to avoid namespace pollution
and easily exceed 20 bytes for a single function name alone.
Of course error handling is often a problem unless you go for
exceptions (terrible, especially if they do not have language
builtin support for file and line number, at least without
-DNDEBUG, imho), general state machines or whatever.

While at C++, the checked automatic upcasts are also very helpful,
especially if you have a deeper object hierarchy.  (As in, struct
object{}, struct drawable{struct object super...}, struct
button{struct drawable super..}, then "drawable d;.. object*=&d
(or for heaven's sake &d.super) is much much better as
&d.super.super or even (object*)&d.)

Damn i have given up on perfection, and sometimes even on
"being explicit is better", but a shame it is.

Ciao, a nice Sunday and Good luck! from Germany,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


More information about the TUHS mailing list