:: Re: [DNG] Studying C as told. (For …
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Peter Olson
Ημερομηνία:  
Προς: Rainer Weikusat, Albert van der Horst
Υ/ο: dng
Αντικείμενο: Re: [DNG] Studying C as told. (For help)
> On June 24, 2016 at 12:45 PM Albert van der Horst <albert@???> wrote:
[...]
> Sorry, but that means your brain is not wired correctly to recognize
> == as the symmetric operation that it is.
> Would you be equally fuzzy about
>     mask = 0x42 & abc;
> versus
>     mask = abc & 0x42;
> ?


I'm perfectly clear about == but the problem I am trying to avoid is typing = when I meant == and having the compiler dutifully obey my clear instructions.

Rainer says modern compilers issue warning about this (and I have improved my code on several occasions by reacting to gcc's warnings about the precedence of & and | for which the compiler is actually doing what I intended, but it was not quite as clear in the source code). Back in the days, I was bitten multiple times by the == vs. = typo. I learned my lesson.

The product of programming is the source code. The executable is a side-effect.

> >
> > So, program in Algol 60/ Pascal/ Modula/ Oberon or "take your := and
> > shove it". The world has moved on.
>
> Not using := but = instead is one of the biggest mistakes in c.
> With Java C++ inheriting it, even Python couldn't get away from it.
> With moving on you mean probably that we must accept that this mistake
> can never be fixed. I for me don't give up hope.


As recently as a year ago I had to use a proprietary robot programming language which used := and I hated it :-) The whole idea of := or assignment in general is suspect. Use a functional programming language like Scheme/LISP, Haskell, or OCAML instead.

> Not trying to start a flamewar. Just demonstrating that there is a
> different opinion possible regards this.


:-)

Peter Olson