• Zatapatique (unregistered)
    message.frist = !string.IsNullOrEmpty(fristMessage) ? true : false;
  • (nodebb)

    There are 10 types of people: those who get binary, and those who don't. I fall in the category: File not found.

  • (nodebb)

    I worked at a company a long, long time ago, where they basically imported their C++ development rules over to C#.

    So back in the old days, C/C++ technically had no boolean type, so the idea was that you transform the integer result of the variable with an tertiary operation into the constants TRUE and FALSE to make it more readable.

    When I see this example, it reminds me about that company. Maybe the code is the same or the "lead" architect from back then read the same book with this crazy idea of "readability" as those guys? Who knows, but here you got an explanation I encountered for this "pattern" in C/C++ in the 90s - obviously it made never ever sense for C# because that language had a boolean type and exceptions form the start.

    Addendum 2024-08-19 07:22:

    of the variable

    Of the result of the method obviously.

  • (nodebb)

    The only way that'd have been better is if they'd left the leading ! off and the results of the ternary were .. ? false : true ;. With the "explanation" that a) negation is difficult to understand and b) the ! symbol is easy to overlook when reading code.

    Now there's a thin vertical stripe of truth in point b. Had we settled on ~ for negation there would be fewer sloppy reading errors in boolean expressions. Instead we'd misread whatever the ! was used for instead. :forehead smack:

  • TheCPUWizard (unregistered)

    In the first version set a breakpoint when setting visible to false..... Now do the same in the "improved" versions...

  • (nodebb) in reply to MaxiTB

    C++ has always had a boolean data type since the beginning, even in the pre-standardization C++98 version.

    C originally did not have a boolean data type, so the usual thing to do was to use int instead. The C99 version of the standard introduced a boolean type, but many compilers didn't support C99 for a while, and many devs still used the older C89 even when a C99 compiler was available. (That said, even if a C99 compiler wasn't available, it was still very trivial for devs to implement their own boolean using a typedef or macro.)

  • Officer Johnny Holzkopf (unregistered) in reply to WTFGuy

    It could be much worse if they introduced ambiguous (or at least "not so easy to parse") naming into things, combined with multiple negation, on "word level" and "code level":

    pnlErrorMessage.Invisible = !string.IsNullOrEmptyOrBoth(errorMsg.toString()) ? untrue : notFalse;

    if (!(pnlErrorMessage.Invisible != FILE_NOT_FOUND) > TrueOrFalse) doSomething(); // or maybe don't?

    A nice negation symbol could have been the ¬ symbol, known as "lazy L", which is present in EBCDIC (and used, for example, in REXX) and even included in extended ASCII as 172 or 0xAC, but it never made its way to PC keyboards...

  • (nodebb) in reply to adamantoise

    (That said, even if a C99 compiler wasn't available, it was still very trivial for devs to implement their own boolean using a typedef or macro.)

    Yes but no. A C-ish set of defines and typedefs wouldn't achieve the key piece of a C++ bool, collapsing all non-zero / non-nullptr values into true. Well, unless the macros include a set-to method that includes a != 0 (being thankful once more that a literal 0 casts trivially to any pointer type as NULL or nullptr).

    But as soon as you do typedef unsigned int bool; followed by bool boolvar = XXX; where XXX is of type unsigned long long, and of a value that's an integer multiple of UINT_MAX+1LL, you get a surprise.

  • 56indepenent (unregistered) in reply to Officer Johnny Holzkopf

    Actually, the lazy l is quite common on UK keyboards and i was always confused what it was usable for.

  • (nodebb) in reply to Officer Johnny Holzkopf

    A nice negation symbol could have been the ¬ symbol, known as "lazy L", which is present in EBCDIC (and used, for example, in REXX) and even included in extended ASCII as 172 or 0xAC, but it never made its way to PC keyboards...

    The Unreliable Source would like to point out, at https://en.wikipedia.org/wiki/British_and_American_keyboards , that that last part of your sentence ("never made its way to PC keyboards") isn't true as an absolute statement. On a UK-QWERTY keyboard, it's the shifted backtick top-left of the main keyboard, next to the 1/! key.

  • TheCPUWizard (unregistered) in reply to WTFGuy

    The only way that'd have been better is if they'd left the leading ! off and the results of the ternary were .. ? false : true ;

    Or be consistent: (!condition) ? !false : !true

  • (nodebb) in reply to adamantoise

    I am aware of that; with not having a boolean type I mean that a lot of library results still often used int for boolean results (hence the technically because with C/C++ library stack is was back in the days a extreme mishmash).

  • Stefan B (unregistered) in reply to TheCPUWizard

    Use a conditional breakpoint?

  • Duke of New York (unregistered)

    “in some ways too concise”: tell it to the APL/J/K folks. Yes, they’re still around, coding blazingly fast trading bots for investment firms.

  • löchlein deluxe (unregistered) in reply to WTFGuy

    Also, and this doesn't even register for most of us readers, you need to have an understanding about operator order (namely that negation binds very tightly and ternary is about as loose as you can get, so it's (!thing)? true:false, not ! (thing?true:false). Even more so because C-style languages' mandatory parentheses in if ()statements.

  • (nodebb)

    For the type that can have the fewest possible values, booleans are one of the most misunderstood types

    The type with the fewest possible values—not counting the unit type, which has one possible value; or the bottom type, which doesn't have any.

  • LZ79LRU (unregistered)

    I knew someone once who refused to use false. Instead he always wrote !true. He rarely was wrong, but we knew all along the damage his method could do.

    One day last July, when the weather was dry and the sun incessantly burned.

    A deadline was looming, and he went on terning. Tern after tern after tern.

    We still to this day know not what went array. Which pointer or he failed to release. All that we know is that there'll be no more snow and that summer shall newer more cease.

    For up in the heavens, forever deployed, now lives an unfortunate !. And the shutdown button to turn off the summer forever refuses to click.

Leave a comment on “Tern on the Error Message”

Log In or post as a guest

Replying to comment #:

« Return to Article