Reputation
4,625
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
10 25
Newest
 Nice Answer
Impact
~177k people reached

  • 0 posts edited
  • 5 helpful flags
  • 141 votes cast
Apr
28
comment Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
The key reason few languages implement this feature is that before Guido, nobody even thought about it. The languages that inherit from C can't get this "right" (mathematically right) now primarily because the developers of C got it "wrong" (mathematically wrong) over 40 years ago. There's lots of code out there that depends on the counterintuitive nature of how those languages interpret x<y<z. A language has once chance to get something like this right, and that one chance is at the language's inception.
Apr
28
comment Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
I'm one of the downvoters on this accepted answer. (@JesseTG: Please unaccept this answer.) This question confuses what x<y<z means, or more importantly, x<y<=z. This answer interprets x<y<z as a trinary operator. That is exactly how this well-defined mathematical expression should not be interpreted. x<y<z is instead shorthand for (x<y)&&(y<z). The individual comparisons are still binary.
Apr
28
comment Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
@SethBattin -- This is not a debugging nightmare in Python. The only problem in Python is if x == y is True : ..., My opinion: People who write that kind of code deserve to be subjected to some extra-special, extraordinary kind of torture that (if he was alive now) would make Torquemada himself faint.
Apr
28
answered Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
Apr
28
comment Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
If one's goal is to design a language that eliminates all things that might be confusing to the most foolish of programmers, such a language already exists: COBOL. I'd rather use python, myself, where one can indeed write a < b > c < d > e < f > g, with the "obvious" meaning (a < b) and (b > c) and (c < d) and (d > e) and (e < f) and (f > g). Just because you can write that does not mean you should. Eliminating such monstrosities is the purview of code review. On the other hand, writing 0 < x < 8 in python has the obvious (no scare quotes) meaning that x lies between 0 and 8, exclusive.
Apr
28
comment Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
Finally, a good answer. It's too bad this is buried beneath a bunch of other answers. This is one of the things I like about python. The python implementation of $a<b<c<...<z$ has the exact same meaning as that expression has to a mathematician.
Apr
28
comment Why do most mainstream languages not support “x < y < z” syntax for 3-way Boolean comparisons?
@ErikEidt - The demand is being able to write mathematical expressions the way we were taught in high school (or earlier). Everyone who is mathematically inclined knows what $a<b<c<d$ means. Just because a feature exists does not mean you have to use it. Those who don't like it can always make a personal or project rule banning its use.
Apr
22
revised Should we be hosting code online?
added 69 characters in body
Apr
22
answered Should we be hosting code online?
Apr
22
comment Should we be hosting code online?
@Pimgd, you missed my point, mainly because I wasn't writing clearly. Google was one of the first to provide a service for hosting code "in the cloud." That service is gone; Google Code no longer exists. There's always a risk that github.com (or whatever alternative provider one chooses) will go poof in a cloud of bankruptcy, or that github.com (or whatever alternative provider one chooses) will decide that hosting private repos is no longer in their interest.
Apr
22
comment Should we be hosting code online?
Since this is a list question, another con to add to your list: what if the hosting organization goes the way of Google Code?
Apr
21
revised Naming when having to inherit classes
added 3 characters in body
Apr
21
answered Naming when having to inherit classes
Apr
16
answered Why don't languages that have big integer support have unsigned versions?
Apr
16
comment How is brainfuck turing complete
Your computer is not a "Turing-complete machine". A Turing machine is a nice fiction that has infinite memory and and can use an infinite amount of time to perform calculations. A programming language can be Turing complete, but a real computer cannot be a "Turing-complete machine".
Apr
12
comment Theoretically bug-free programs
Perhaps a better example of an SEU changing the call to Add to LaunchMissiles would be an SEU changing some data value that eventually results in an erroneous call to LaunchMissiles. SEUs are a problem with computers that go into space. This is why modern spacecraft oftentimes fly multiple computers. This adds a new set of problems, concurrency and redundancy management.
Apr
11
answered Why does everyone use Git in a centralized manner?
Apr
6
awarded  Nice Answer
Apr
4
answered How aggressively to change in-house smart pointer to unique_ptr?
Apr
2
comment How can I represent a multi-dimensional grid?
I voted to close as "too broad". Attempting to solve this problem has lead to multiple packages (CDF & NetCDF, HDF4&5, GRiB, numpy/scipy, ...), and even multiple languages (APL, Fortran, MATLAB, R, ...).