Parenthesis
Wolven
rma at wolven.net
Sat Dec 23 02:44:16 PST 2006
== Quote from Steve Horne (stephenwantshornenospam100 at aol.com)'s article
> Trying to get the best of both worlds risks bringing in a whole bunch
> of new problems...
> if a == b // fine
> {
> ...
> }
> if a == b return c; // errm - well...
> if a == b *c++; // aaarrrggghhh!!!
Forgive me for my ignorance (I've never programmed in C), but what isn't clear
about those statements?
> if a == b return c; // errm - well...
This one seems perfectly clear to me. Maybe I'm reading it wrong. To me, it
says; if a equals b then return and pass back c. Is that not correct?
> if a == b *c++; // aaarrrggghhh!!!
Likewise, this one says; if a is equal to b, add one to... pointer c? Although
I'm not positive of the meaning of the *, everything else seems crystal clear.
Again, am I not reading it correctly? Other than my uncertainty over the *, I
don't see any ambiguity in those statements... or any reason why C(++)
programmers don't like them. But since I'm not a C(++) programmer, perhaps
there's something unclear about those statements that I'm just not recognizing.
As for the a = b + c * d statement... The only thing I need to know is, Does the
language use the standard arithmetic precedence? If it does, then the statement
means a = b + (c * d) otherwise I'd just use standard left to right evaluation...
i.e. a = (b + c) * d. Other than a quick check of the language reference (which
I SHOULD only need to do once ) to see how it handles arithmetic precedence (or
not) where's the ambiguity?
By the way, I'm not suggesting that D should be modified to use this style of
syntax. I understand completely that it is INTENTIONALLY "C like" to make it
easy(er) for C(++) programmers to adapt to. So please don't take my comments as
arguing for any change. I'm just trying to understand WHY C(++) programmers find
statements that seem perfectly clear to me, confusing.
More information about the Digitalmars-d
mailing list