4 ms·
I said it was a sensible response to a non-sensible operation. The operation of flooring "banana" is not semantically-correct. The fact that IEEE floating point
by jdmichal 10y ago
I said it was a sensible response to a non-sensible operation. The operation of flooring "banana" is not semantically-correct. The fact that IEEE floating point numbers happens to have a value that provides a sensible result to this operation is a bit of a fluke. What if the return value was an integer type, which is perfectly valid considering that the floor operation always provides an integer result?
- kbenson 10y agoWhat is sensible is first based on the language definition, not your opinion. If the language defines it explicitly and has well defined rules, there's nothing non-sensible about it. Consider the following, which fall well within the definition of how Perl handles implicit conversion of strings to numeric types, and is well known to Perl programmers: # perl -E 'say "1zero"+0 ' 1 # perl -E 'say "zero1"+0 ' 0
- jdmichal 10y agoNo, I'm pretty sure that the question "what's the mathematical floor of banana" doesn't make any sense, no matter what the language definition is. The fact that some (dynamic) languages even allow you to ask the question is the entire point being made by kodablah in regards to typing as a safety mechanism. The fact that some smaller subset of languages even attempt (and fail) to make sense of the operation (weak typing) is just diving straight off the deep-end of safety.
- kbenson 10y agoI'm not sure there's a point in continuing this when I've defined, multiple times, the definition of safety I'm working under for the purposes of this discussion and my point, and you willfully ignore it to argue something entirely different time and again. I'm not interesting in discussing the merits of dynamic vs static languages, nor weak vs strong typing, when this started out as if you have a language feature that might cause a crash under normal, expected allowed behavior within the language, and one that will not cause a crash a a very small performance draw for that specific operation, I think defaulting to the non-crashing operation is the correct choice. Feel free to speak to that point if you would like to continue, because I don't see how the current tangent applies.
- jdmichal 10y agoThe entire point of this "tangent" (which it isn't) is that the same reason you would make the choice to use the "unsafe" variant are the same reasons you would argue to not use a type-safe language. Or, rather, if you're default inclination is to always choose safety over other factors, then why not apply the same logic to languages? The fact is that you seem to be drawing an arbitrary line at language-use in your logic here.