Ada extended truthyness :Tribooleans
-
Now fun truthyness in critical systems too!
I just saw this and though deserved sharing.
-
FILE_NOT_FOUND
lives!
-
Python has tribooleans too:
>>> (True or None, False or None, True and None, False and None) (True, None, None, False) >>>
-
yeah lots of languages do that sort of stuff, still when I read their example motivation talking about databases I just thought
-
The Trouble With Tribooleans
-
-
Next question: why does a restart almost wipe them out?
-
-
```
- Killing all remaining processes
http://educatinggeeks.com/wp-content/uploads/2014/05/errandofmercyhd572.jpg</blockquote> That doesn't explain the ***almost***.
-
Well, one of the guys that's responsible for the cleanup is... not always efficient
Filed under: This turned into "@Onyx posts Star Trek images" thread, hasn't it?
-
-
I hereby apologize to @Piko as it wasn't my intention. You bastards made me do it!
-
-
Python has tribooleans too:
>>> (True or None, False or None, True and None, False and None) (True, None, None, False) ```</blockquote> I'll bait. You got two booleans and two "nones". Three different values, but only two different *boolean* values Python's **and** and **or** operators return the last operand they evaluate. ```python >>>map(type, (True or None, False or None, True and None, False and None)) [<type 'bool'>, <type 'NoneType'>, <type 'NoneType'>, <type 'bool'>] >>> map(lambda x : True if x else False, (True or None, False or None, True and None, False and None)) [True, False, False, False] >>> map(lambda x : False if not x else True, (True or None, False or None, True and None, False and None)) [True, False, False, False]
-
still when I read their example motivation talking about databases I just thought
You need some kind of nullable bool to talk to a DB server that has a nullable bool.
Natch, C#'s solution to this problem is much more elegant.
-
do you mean
bool?
orDBNULL
?because i'm only able to agree with you one one of those.
-
Depends on how you're getting the data out? I'd imagine that, when using an ORM layer,
bool?
is better, but using ADO.NET directly,DBNull.Value
is preferable.
-
i go through an ORM almost exclusively.
although the ORM i go through is pretty much just a Linq2SQL class that i added a bunch of SPROC objects to that the data team ehre gave me.
i try to avoid raw ADO.NET if i can possibly avoid it because that makes my fur fall out.
-
makes my fur fall out
DO NOT WANTI've used raw ADO.NET before; it is quite a pain in the quills. I'm not saying the ORM I use now is the right way to do it (I'm not sure my company's using it right actually), but I do know I prefer having it sort out converting all those
DBNull.Value
s intoT?
s.
-
hence my original comment. :-P
-
You have a point, anyway reading the example doesn't give a feeling that that's what they are thinking, Then again i'm not sure what they where thinking.
some optional boolean criteria (“must the contact be french?”). He can choose to only see french people (“True”), to see no french people at all (“False”), or to get all contacts (“Indeterminate”). With a classical boolean, there is no way to cover all these cases.
That's the relevant bit I was speaking of.
I poked around a bit with the gnatcoll sql interface and they don't seem to be using this type. Still i might be wrong and TRWTF.