Re:Elevator Saga – An elevator programming game
by _lce0 on Friday January 23, 2015 @12:04PM
(#8935902)
I think one problem with statements-as-expression is that is not always evident which should be their result.
for instance:
bool r = if (test()) {
false;
} else {
true;
}
what r should be set to? true or false?I don't see the point of adding such complexity.. it's waaay more clear to be explicit
bool r = test();
if (r) {
false;
} else {
true;
}
or, if you intended the other way bool r;
if (test()) {
r = false;
} else {
r = true;
}
I guess that's why you need to be strictly correct, or highly opinionated, to design a language.
Re:Elevator Saga – An elevator programming game
by JoeAltmaier on Friday January 23, 2015 @02:06PM
(#8936595)
I'm missing your point I guess. All those are equivalent?
In C an assignment has the value of the RHS, so that doesn't change anything in these examples.
Re:Elevator Saga – An elevator programming game
by molo on Tuesday January 27, 2015 @01:23PM
(#8954695)
That is unnecessary verbosity. Try this instead:
bool r = !test();
Re:Elevator Saga – An elevator programming game
by thedufer on Friday January 23, 2015 @01:21AM
(#8933642)
Have you tried coffeescript? Your examples are pretty close to valid code that does what you want.
e.g.
or