On Tuesday 22. October 2013 18.01.10 Werner Almesberger wrote:
> [ Came across a security-related article that made me think of an
>   old and constant gripe of mine. Here's my rant, somewhat off-topic. ]

It's always interesting to read these kinds of rants, particularly after doing 
a bit of C programming for the Ben and getting some of these compiler 
warnings. ;-)

Actually, I've been trying to track down a presentation about C language 
misbehaviour and misconceptions that someone posted to the IRC channel a while 
ago, featuring some kind of cartoon figure showing off different code 
examples, soliciting audience opinions, and then demonstrating that the code 
doesn't behave at all as they would expect. I think it was a PDF.

Paul

P.S. Of course, assignments in expressions are not permitted in some languages 
(like Python) for good reason, but I now find myself bringing habits from 
those languages to C. For example:

good_to_go = (a > 10) || (a == 0);

/* Some time later... */

if (good_to_go) ...

Such transient boolean variables wouldn't have really occurred to me when I 
first learned C, but labelling conditions in this way is often rather useful. 
If the conditions were only used once, a smart compiler could probably defer 
the evaluation and avoid storing the result, but that missing presentation 
would have something to say about that, I'm sure.

_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to