On Fri, Apr 04, 2014 at 00:59:23 +0000, Meta wrote: > His examination of the compare function was interesting. I think, > though, that it's misguided, and not one of Scala's problems.
Maybe not major, but it's not completely ignorable. > Returning an int to denote less than, equal, and greater than is a > very small complexity, and makes it very fast to check the result. See, this is *exactly* his point. You're basically putting the "well, C does it" and "int is fast" as your rationale. I think by this point, we (as a collective community) have seen that C has some serious flaws when you start allowing user input from untrusted sources into your code. The latter is easily classified as premature optimization. There is *zero* rationale as to why this would be a compilable implementation of comparison: int compare(int a, int b) { return a * b; } The fact that this compiles when used as a comparison is *insane* when you take a fresh look at how you can construct a language. If you have sum types, you can both deny the above silliness and represent it as an integer and be just fine. In fact, you're possibly better off since you can now do: add $offset $compare_result jmp *$offset rather than doing 2 comparisons and a branch since you *know* the result will never be more than 2. --Ben