syntax

Nov 22, 2009 at 1:37pm
Why are some arguments enclosed in parentheses?

(first == second) ? "equal" : "not equal";
Nov 22, 2009 at 1:52pm
Sometimes (in your case too) just to make things clearer, other times to override operator precedence just like in mathematics.
http://www.cplusplus.com/doc/tutorial/operators/
Last edited on Nov 22, 2009 at 1:52pm
Nov 22, 2009 at 3:20pm
closed account (S6k9GNh0)
It's recommended to always use parenthesis to help clarify the order of things. If you don't know if you should use parenthesis or not, as a rule of thumb, just use parenthesis.
Last edited on Dec 2, 2009 at 5:53pm
Nov 22, 2009 at 5:33pm
I always use paranthesis. Even for obvious things like (x * 5) + 3. Makes it so much easier to read.
Nov 22, 2009 at 7:24pm
Ever thought programming in Lisp?
Nov 22, 2009 at 7:31pm
Hahaha

Well I never have THAT many parenthesis. I avoid compound statements as much as possible. Nothing wrong with new lines and whitespace.
Nov 23, 2009 at 2:57pm
Extra parens do not always enhance readability, IMHO.

After all, most people don't do things like:

( ( cout << "Hello " ) << "World ) << endl;

or

memcpy( ( dest ), ( src ), ( sizeof( src ) ) );


Most people use parens, as computerequip stated, to clarify things. But the problem is
that what is not clear to one person is perfectly clear to another, and in the latter case
the parens are just syntactic baggage.
Nov 23, 2009 at 4:24pm
Thanks, so parens are used to help clarify statements and used for c++ syntax; as in type casting.

LOL, on Lisp programming!

Topic archived. No new replies allowed.