|
![](/i/fill.gif) |
Invisible wrote:
> "while (!(*i < *--j)) {}"
C has always advocated piling up a bunch of side effects inside
conditionals. Even to the point where Google's go has completely useless
syntax for doing so.
In go, you can write
if x := y + 1; x > 5 { ... }
Which is always exactly precisely the same as
x := y + 1;
if x > 5 { ... }
Since you *always* need braces, and the result of evaluating the assignment
isn't ever used as the conditional, it's just a way of embedding
side-effects into a part of a statement that should be side-effect free,
apparently because the people designing go are so used to C's actually
*useful* side effects that they missed the result.
The above line could also be
do { j -= 1; } while (*j <= *i);
(or maybe while *i < *j. I don't care to work it out for sure)
So, yeah, it's opaque C++ code there.
> Um, yeah, "interesting" would be the term I'd use. WTF? o_O
The algorithm is interesting, not the implementation.
--
Darren New, San Diego CA, USA (PST)
Human nature dictates that toothpaste tubes spend
much longer being almost empty than almost full.
Post a reply to this message
|
![](/i/fill.gif) |