Ada extended truthyness :Tribooleans



  • Now fun truthyness in critical systems too!

    I just saw this and though deserved sharing.


  • BINNED

    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 :wtf:



  • The Trouble With Tribooleans


  • BINNED

    @Bort said:

    The Trouble With Tribooleans

    Guys, we may have figured out what server cooties are...


  • mod

    Next question: why does a restart almost wipe them out?


  • BINNED

    * Killing all remaining processes
    

  • mod

    @Onyx said:

    ```

    • Killing all remaining processes
    
    http://educatinggeeks.com/wp-content/uploads/2014/05/errandofmercyhd572.jpg</blockquote>
    
    That doesn't explain the ***almost***.

  • BINNED

    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?


  • SockDev

    @Onyx said:

    This turned into "@Onyx posts Star Trek images" thread, hasn't it?

    Yes :P


  • BINNED

    I hereby apologize to @Piko as it wasn't my intention. You bastards made me do it!


  • SockDev

    @Onyx said:

    You bastards made me do it!

    :clap:
    again! again!

    Bravo! Bravo ragazza!



  • @VinDuv said:

    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]
    


  • @Piko said:

    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.


  • SockDev

    do you mean bool? or DBNULL?

    because i'm only able to agree with you one one of those.


  • SockDev

    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.


  • SockDev

    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.


  • SockDev

    @accalia said:

    makes my fur fall out

    DO NOT WANT

    I'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.Values into T?s.


  • SockDev

    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.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.