From: Ivan Cenov Date: 2013-01-07T06:24:53+09:00 Subject: Re: Best practice for &&, ||, and, or This is a multi-part message in MIME format. --------------010801020507080505070908 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit На 6.1.2013 г. 21:30 ч., Admin Tensor написа: > unknown wrote in post #1091219: >> Exactly. This discussion has confirmed my tendency to only teach >> &&, || (for boolean expressions, assignments with defaults, ...) >> and leave control flow to if/unless. >> >> Myself, I use constructs like `do_something or do_other' >> very seldom anyway. > Yup. The way && and || work is like almost all other languages. But > because "and" and "or" has lower precedence and "and" has the same > precedence as "or", I almost never use them. (If you switch from > language to language, you know what I mean.) > > Regards, > > Bill > Hi, I am a C programmer and have to comply the code with MISRA rules. According to these rules programmers should not rely on precedence of the operators. They state to use [redundant] parenthesizes () instead. So when an expression is too complicated, ( and ) would be in help. -- Regards, Ivan Cenov OKTO-7 Co. Bulgaria imc@okto7.com, i_cenov@botevgrad.com mobile:+359888761080, phone:+35972366161, fax:+35972366262 Let's make better business with http://www.redmine.org --------------010801020507080505070908 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
На 6.1.2013 г. 21:30 ч., Admin Tensor написа:
unknown wrote in post #1091219:
Exactly. This discussion has confirmed my tendency to only teach
&&, || (for boolean expressions, assignments with defaults, ...)
and leave control flow to if/unless.

Myself, I use constructs like `do_something or do_other'
very seldom anyway.
Yup.  The way && and || work is like almost all other languages.  But
because "and" and "or" has lower precedence and "and" has the same
precedence as "or", I almost never use them.  (If you switch from
language to language, you know what I mean.)

Regards,

Bill

Hi,
I am a C programmer and have to comply the code with MISRA rules.
According to these rules programmers should not rely on precedence of the
operators. They state to use [redundant] parenthesizes () instead.
So when an expression is too complicated, ( and ) would be in help.

--

Regards,

Ivan Cenov
OKTO-7 Co. Bulgaria
imc@okto7.com, i_cenov@botevgrad.com
mobile:+359888761080,
phone:+35972366161, fax:+35972366262
Let's make better business with http://www.redmine.org

--------------010801020507080505070908--