:: Re: [DNG] Studying C as told. (For …
Inizio della pagina
Delete this message
Reply to this message
Autore: Rainer Weikusat
Data:  
To: dng
Oggetto: Re: [DNG] Studying C as told. (For help)
Albert van der Horst <albert@???> writes:

[...]

>>> Another habit I have is to avoid a statement like:
>>>
>>>     if (abc == 42)

>>>
>>> and write it as
>>>
>>>     if (42 == abc)

>>>
>>> instead.
>>
>> That's a habit of many people who either believe to be master yoda
>> ('Your sister she is') or who believe their heart-felt support for
>> Nikolaus Wirth is so important that it trumps writing clear code.
>
> 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;
> ?


Absolutely, although the phenomenon is less striking there. If you want
a mathematical example, picture somone always writing

x / (1/n)

instead of

x * n

Questions in spoken language as for properties of objects ('Is the
colour of the car blue'), not for objects of properties ('Is blue the
color of the car'). This is especially relevant as this 'trick'
doesn't even avoid the perceived problem (as I already wrote) as
l-values may also be compared with other l-values.