7 ms·
Are you seriously suggesting that, widgety though JS's implicit type conversions might be, if its booleans had three values then things would be better?
by fenomas 9y ago
Are you seriously suggesting that, widgety though JS's implicit type conversions might be, if its booleans had three values then things would be better?
- jmfayard 9y agoBooleans having only three values would be an improvement for JavaScript where they actually have four : true, false, null and undefined
- moefh 9y agoThis is nonsense. If typeof(x) is 'boolean', then x is either true or false. Now, if you don't know the type of x and try to use it as boolean without being careful, it might look like it has four values. That comes partly from being dynamically typed and partly from performing coercion instead of throwing errors. So one might argue that Javascript encourages people to write code that's not careful, or that it's very clumsy to write careful code in Javascript, but saying booleans have four values is just nonsense.
- catnaroek 9y agoIt's perfectly okay for a Boolean algebra to have four values. The two extra values can't behave the way JavaScript's “null” and “undefined” do, though. No three-valued Boolean algebra exists.
- deleted 9y ago[deleted]
- lisper 9y agoYes. Why would you doubt it? (i.e. why would you doubt that I'm seriously suggesting it, not why would you doubt that what I am suggesting has merit) (Oh, and BTW, before you completely dismiss the idea that my suggestion might have merit, you might want to look me up. I didn't just fall off the turnip truck.)
- zebraflask 9y agoI am intrigued by your ideas and would like to subscribe to your newsletter. Jokes aside, a 3 value Boolean conditional could have some useful applications.
- eropple 9y agoFWIW, for the downvoters: you really should look 'lisper up. I'm not sure I agree with him but the incredulity shown here is unwise.
- ng12 9y agoSmart people can still say dumb things.
- lisper 9y agoYes, they can indeed.
- curun1r 9y agoThe down votes are likely for trying to invoke an ad hominem argument. No matter someone's credentials, it's still a logical fallacy and something to be avoided. If he is an authority on the subject, it should show through in his comments. I'm sure he's a very smart and knowledgable person. But there are a lot of smart and knowledgable people here and by invoking his credentials, he's presuming that the people he's talking to are less knowledgable, intelligent or entitled to their opinions. It's insulting and he's earned his downs. Full disclosure: I downed his 'look me up' post and upped his more substantive posts.
- eropple 9y agoExcept 'lisper wasn't making an argument. He was responding to a case of somebody being socially jerkish in a way that was pretty gentle, even for HN's coddling standards. That's important, because downvotes don't fix jerks--only pointing out the behavior does. Coming in hot with "oh but fallacies, hmm hmm, heaven forfend" when what's being suggested is "maybe don't be a jerk?" is not a great look, don't you think?
- laichzeit0 9y agoWhy not? SQL has three valued logic. It's not a novel idea.
- fenomas 9y agoI'm aware that SQL has "bit" values that can be 1/0/null, but that's not exactly three valued logic. Does it really have conditional checks that can have three possible outcomes, or something similar?
- JoelJacobson 9y agoYes, a boolean value can be checked for the three possible values, TRUE, FALSE or NULL.
- deleted 9y ago[deleted]
- lomnakkus 9y agoIndeed it does, and it's horribly error-prone because people don't actually understand it :/. It can also lead to quite convoluted query logic because you're giving up the "law of the excluded middle"[1] (amongst other things). For my money, the only sane thing to do with e.g. "null >= 0" is to throw an exception. (Even better would be just rejecting it at compile time, but JS obviously doesn't have that luxury.) [1] https://en.wikipedia.org/wiki/Null_(SQL)#Law_of_the_excluded_fourth_.28in_WHERE_clauses.29 https://en.wikipedia.org/wiki/Null_(SQL)#Law_of_the_excluded... EDIT: Ninja edit: I do understand that NaN has 'reasons', but ideally it'd really want NaN == x to trap rather than just doing 'the weird thing'.
- trollied 9y agoHumans not taking the time to understand SQL properly is their own fault though. Three value logic works perfectly well in the right hands. JavaScript is horrid :(