A Smorgasbord of Classics

« Return to Article
  • Anonymous 2008-09-05 08:06
    Fist!
  • Anonymous 2008-09-05 08:08
    Secodn!
  • anoncow 2008-09-05 08:11
    Turd!
  • Fiona 2008-09-05 08:11
    Thrd!
  • Fiona 2008-09-05 08:11
    HUUUUUUUUURF
  • A Nonny Mouse 2008-09-05 08:20
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If

    looks to me like someone needed a breakpoint while debuggering
  • jimlangrunner 2008-09-05 08:22
    25th! (space)

    No, I didn't count. Had the computer do it for me.

    WTF?
  • Jithu2k1 2008-09-05 08:24
    A Nonny Mouse:
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If

    looks to me like someone needed a breakpoint while debuggering


    looks to me like someone had no clue what he was doing!!!
  • A Nonny Mouse 2008-09-05 08:31
    jimlangrunner:
    25th! (space)

    No, I didn't count. Had the computer do it for me.

    WTF?

    "twenty" is obviously base 12.5
  • snoofle 2008-09-05 08:33
    alex:
    #define false 1
    
    #define true 0

    Brought to you by the same folks who came up with FileNotFound?
  • jimlangrunner 2008-09-05 08:35
    Jithu2k1:
    A Nonny Mouse:
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If

    looks to me like someone needed a breakpoint while debuggering


    looks to me like someone had no clue what he was doing!!!


    Bah. for breakpoints, i=i has always struck me as easy. but then, so am I.
  • Customer Service 2008-09-05 08:36
    Customer requirement one: The date must appear in columns 1 thru 10.

    Customer requirement two: The product description (45 characters) must be right justified to column 80.

    Customer requirement three: There must be twenty spaces between the date and the product description.

    Solution:
    private final static String twentyspaces = "                         ";

    The customer is always right!
  • some coder 2008-09-05 08:37
    I found this in some production code:

    int iChkShut; // variables MUST be initialized, not sure whyFunny enough, the parameter iChkShut is used (uninitialized) for comparisment a couple of rows later.


    Holy bejesus that's funny
  • Stephen Bayer 2008-09-05 08:55
    A Nonny Mouse:
    jimlangrunner:
    25th! (space)

    No, I didn't count. Had the computer do it for me.

    WTF?

    "twenty" is obviously base 12.5


    I was under the impression that bases needed to be whole numbers over 1.. ie. base 2, base 3, base 4, base 5, ... ok.. this could go on for a while.. i think there are a lot more whole numbers over 1. I used to use random bases when doing my fourth grade math homework, then argue with the teacher about the validity of my answers, calling her an idiot for not agreeing with me that 8 + 5 = 11
  • andem 2008-09-05 08:57
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.
  • MiffTheFox 2008-09-05 09:00

    I was under the impression that bases needed to be whole numbers over 1.. ie. base 2, base 3, base 4, base 5, ... ok.. this could go on for a while.. i think there are a lot more whole numbers over 1. I used to use random bases when doing my fourth grade math homework, then argue with the teacher about the validity of my answers, calling her an idiot for not agreeing with me that 8 + 5 = 11


    Okay, thanks for sharing with us what a base is... The point of the joke is that the twentyspaces variable is actually 25 spaces. 20 in "base 12.15" here is equal to 25 base 10.

    If anything, you're the idiot for assuming base 12 on a fourth-grade level problem.
  • NiceWTF 2008-09-05 09:05
    snoofle:
    alex:
    #define false 1
    
    #define true 0

    Brought to you by the same folks who came up with FileNotFound?


    Brought to you by strcmp() and friends, more likely.
  • Mark! 2008-09-05 09:15

    lSend = IIf(lSend = True, True, False)


    As far is I know VB6, lSend doesn't have to be a boolean, ie it can be a Variant. So it could contain other values then true or false. For example, null when read from a db.

    This is an ok trick to get a true/false only (boolean)
  • Dan 2008-09-05 09:15
    if(isGoodComment || !isGoodComment)
    {
    postComment();
    }
  • KenW 2008-09-05 09:16
    Stephen Bayer:
    I was under the impression that bases needed to be whole numbers over 1.


    I was under the impression that everyone who reads here has at least enough intelligence and sense of humor to recognize a joke and therefore not feel the need to correct it. Apparently, I was wrong.

    Thanks for correcting my misunderstanding.
  • KenW 2008-09-05 09:17
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.


    Wow. You'd be really smart if:

    a) You didn't state the obvious.

    b) You realized that the actual WTF wasn't the constant/variable order, but the fact that the same identical comparison was made twice using an OR.

    Thanks for playing, though.
  • Andy Goth 2008-09-05 09:18
    alex:
    #define false 1
    
    #define true 0
    #define ZERO -1
    Remember that? I took a second look at the code, and it turns out I was wrong. Here's how it actually reads:
    #define NEGATIVE_ONE 0
  • Niels 2008-09-05 09:18
        lSend = IIf(lSend = True, True, False)

    Obviously because there are other values than True and False. (FileNotFound etc.)

    In a real language I'd just have done lSend = !!lSend; for it, concise way to force a value to boolean.
  • Thief^ 2008-09-05 09:20
    A Nonny Mouse:
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If

    looks to me like someone needed a breakpoint while debuggering

    A conditional breakpoint, in a debugger that doesn't support them.
  • Thief^ 2008-09-05 09:20
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.
  • jcoehoorn 2008-09-05 09:20
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If


    If you do a lot of batch processing, it's only a matter of time until you write one like this. You'll get an error about 3/4 way through a large dataset and want to step through the code to find it, and so you write a no-op snippet like that so you can set a break point when it reaches the record that's causing the problem. But that could should never make it to production.
  • --- 2008-09-05 09:25
    Thief^:
    A Nonny Mouse:
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If

    looks to me like someone needed a breakpoint while debuggering

    A conditional breakpoint, in a debugger that doesn't support them.


    Yeah I've done that. I think conditional breakpoints were there, but made everything run so slowly it was basically unusable (it was on a PS2 compiler I think).
  • n0t 1337 h4xx0r 2008-09-05 09:25
    #define false 1
    #define true 0

    I've seen such a construction hidden deep inside some header... There was a comment: "Happy debugging, d*ckhead!";
  • blah 2008-09-05 09:30
    comparisment?
  • Steve Boyko 2008-09-05 09:35
    If (Mid(CStr(cppObject.GetValue()), 1, 1) = "-") Then ...

    Silly old bear, the programmer should have used Left rather than Mid. Saves a few keystrokes. ;)
  • Hope that helps 2008-09-05 09:36
    blah:
    comparisment?

    Comparisment is used to avoid embarrison.
  • J. Palmer 2008-09-05 09:36
    It wasn't a bug after all...
  • Andy Goth 2008-09-05 09:39
    Stephen Bayer:
    I was under the impression that bases needed to be whole numbers over 1.
    A number base (a.k.a. radix) does not need to be a whole number; that just makes it easier to work with. The Unix DC program (or at least the dc.sed version) supports fractional input and output radixes, via the 'i' and 'o' commands. Type 12.5;i;20;p; (replacing ; with newlines), and it'll print 25. Take the input number 20, expand it to 2*(12.5**1)+0*(12.5**0), and you get 25. If dc has a fractional output base, it's forced to spell out each "digit" as a decimal number, separating the "digits" with spaces. For example, 3.4;o;20;p; yields 1 1.6 3.0, since 1*(3.4**2)+1.6*(3.4**1)+3*(3.4**0) = 20.
  • WhiskeyJack 2008-09-05 09:40
    Ah, someone beat me to it. Comparisment is a word now?
  • Someone You Know 2008-09-05 09:44
    WhiskeyJack:
    Ah, someone beat me to it. Comparisment is a word now?


    And a perfectly cromulent one at that.
  • Somer Himpson 2008-09-05 09:45
    if (connected || !connected)
    {
    return file_not_found;
    }
  • Hope that helps 2008-09-05 09:45
    WhiskeyJack:
    Ah, someone beat me to it. Comparisment is a word now?
    http://www.comparisment.com/ is a registered domain, so the word must be in some dictionary somewhere!
  • diaphanein 2008-09-05 09:48
    ** the following code is neither recyclable or reusable
    ** but rather highly radioactive toxic sludge
    ** liable to give you hemmorragic brain damage and anal leakage of the mouth
  • diaphanein 2008-09-05 09:50
    ** the following code is neither recyclable or reusable
    ** but rather highly radioactive toxic sludge
    ** liable to give you hemmorragic brain damage and anal leakage of the mouth
  • diaphanein 2008-09-05 09:50
    ** the following code is neither recyclable or reusable
    ** but rather highly radioactive toxic sludge
    ** liable to give you hemmorragic brain damage and anal leakage of the mouth
  • Vechni 2008-09-05 09:50
    lol, web squatters.
  • Satanicpuppy 2008-09-05 09:52
    Some of the conditional stuff I can see; you write it, you change it, you write it, you change it, you write it and FINALLY the data matches what it's supposed to and you don't recheck.

    The "20 spaces" I understand as well, though you should never ever ever do that. On old COBOL systems you have a lot of "Fixed Width" flat table databases, and huge chunks of spaces are actually really necessary for running through those, though I'm sure everyone here understands that you should never use more than 1 space at a time to avoid counting errors, and indeed, that more than 1 space isn't useful except in really ugly constructions like:

    $line = $valueA.twentySpaces.$valueC.$twentyTwospaces.$valueC;

  • Paul Carpenter 2008-09-05 09:55
    #define false 1
    #define true 0

    The source for the game Power Sports Soccer had something similar, along with

    #define BEGIN {
    #define END }
    #define FOR for
    #define IF if
    #define THEN {
    #define ELSE } else {
    #define ENDIF }

    There was an include file with about 30 more nuggets like that in it...
  • Kuba 2008-09-05 09:59
    A Nonny Mouse:
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If
    looks to me like someone needed a breakpoint while debuggering
    That's why I have always been at loss why some standard C header is not forced to include something to the effect of
    #define NOP() asm("nop");
    I have a header in my library of "useful stuff" that does include this. It is quite cross-platform, too!

    Cheers, Kuba
  • Kevin 2008-09-05 10:21
    The company that I work for has an internal application for product / stock management written in VBScript... And, as you can see here, they have great security.


    If Len(Trim(fParentFrames2.sGetSecurityRights())) > 0 Then

    or

    '*** 2004-06-17 - Jdepo - Security
    iResults = 1


    They also have great version control, including inline changelogs!

    'Commented by NMURUG (Cognizant) to fix the defect# 842 on 25 Jul 2007 - Start Change
    'btnMyInfo.value = "My Info"
    'Commented by NMURUG (Cognizant) to fix the defect# 842 on 25 Jul 2007 - End Change
  • Ale 2008-09-05 10:21
    if (connected || !connected)
    {
    //ED: Snip
    }

    He just doesn't want the code to run if connected = FileNotFound
  • rosko 2008-09-05 10:33
    Mark!:

    lSend = IIf(lSend = True, True, False)

    As far is I know VB6, lSend doesn't have to be a boolean, ie it can be a Variant. So it could contain other values then true or false. For example, null when read from a db.

    This is an ok trick to get a true/false only (boolean)

    Or you could just use CBool(lSend)
  • HeavyBoy 2008-09-05 10:42
    javascript:alert(" ".length);
  • moz 2008-09-05 10:48
    Andy Goth:
    If dc has a fractional output base, it's forced to spell out each "digit" as a decimal number, separating the "digits" with spaces. For example, 3.4;o;20;p; yields 1 1.6 3.0, since 1*(3.4**2)+1.6*(3.4**1)+3*(3.4**0) = 20.
    I wonder why it chooses to print that "number", rather than 121.2.
  • Steve 2008-09-05 10:49
    Regarding the final item, a number of years ago I had a discussion over a few Tsing Taos with some VMS weenies (er, hackers) about the proper values for true and false. Their contention was that since in VMS a return value of zero indicates success and any other value returned indicates failure of a function or operation, it makes sense that 1 (or any nonzero value) should be interpreted as false and only 0 be interpreted as true.

    They considered the C language's use of 0 as a false value to be a significant wart on the language.

    I can say that after many Tsing Taos and several servings of Kung Pao Death I was inclined to agree.
  • Steve 2008-09-05 11:04
    Paul Carpenter:
    #define false 1
    #define true 0

    The source for the game Power Sports Soccer had something similar, along with

    #define BEGIN {
    #define END }
    #define FOR for
    #define IF if
    #define THEN {
    #define ELSE } else {
    #define ENDIF }

    There was an include file with about 30 more nuggets like that in it...
    Ah, yes, the hallmark of a beginning C programmer who has just discovered macros.

    By the way, in the original K&R book, there's even a brief discussion of this:
    The C Programming Language, pp. 86-67:
    Since the imlementation of #define is a macro prepass, not part of the compiler proper, there are very few grammatical restrictions on what can be defined. For example, Algol fans can say

    #define then
    
    #define begin {
    #define end ;}
    and then write
    if ( i > 0 ) then
    
    begin
    a = 1;
    b = 2
    end
    Thus spake K&R and endeth the lesson.

    I seem to recall that elsewhere they counsel against the practice however I can't find it
  • cparker 2008-09-05 11:24
    Christophe Beugnet:
    #define false 1
    #define true 0
    Little did Christophe know, he was developing with April Fool's C.
  • Kehvarl 2008-09-05 11:47
    Fiona:
    HUUUUUUUUURF


    It's a hippopotomus! It's not my cow!!
  • Zap Brannigan 2008-09-05 11:56
    Thief^:
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.

    I also make all of my comparisons twice. It's the only way to be really really sure.
  • SomeCoder 2008-09-05 12:14
    Let me just say that I love C/C++ but it lets you get WAY too carried away with defines. When you can say #define false 1... that's trouble.
  • Harrow 2008-09-05 12:15
    Steve:
    Regarding the final item, a number of years ago I had a discussion over a few Tsing Taos with some VMS weenies (er, hackers) about the proper values for true and false. Their contention was that since in VMS a return value of zero indicates success and any other value returned indicates failure of a function or operation, it makes sense that 1 (or any nonzero value) should be interpreted as false and only 0 be interpreted as true.

    They considered the C language's use of 0 as a false value to be a significant wart on the language.

    I can say that after many Tsing Taos and several servings of Kung Pao Death I was inclined to agree.

    I worked at DEC for years. I argued that the meaning of the argument returned from a VMS SVC function should answer the question "Did it fail?" and therefore zero is false and any nonzero is true. But VMS weenies were an alien breed, from a strange planet where mental effort is regarded as evil.

    -Harrow.
  • RealLanguage 2008-09-05 12:24
    Niels:
        lSend = IIf(lSend = True, True, False)

    Obviously because there are other values than True and False. (FileNotFound etc.)

    In a real language I'd just have done lSend = !!lSend; for it, concise way to force a value to boolean.


    I hope you're joking... in a language worth anything, you wouldn't have to do this in the first place. It's called "strong static typing".
  • RealLanguage 2008-09-05 12:27
    Steve:
    Regarding the final item, a number of years ago I had a discussion over a few Tsing Taos with some VMS weenies (er, hackers) about the proper values for true and false. Their contention was that since in VMS a return value of zero indicates success and any other value returned indicates failure of a function or operation, it makes sense that 1 (or any nonzero value) should be interpreted as false and only 0 be interpreted as true.

    They considered the C language's use of 0 as a false value to be a significant wart on the language.

    I can say that after many Tsing Taos and several servings of Kung Pao Death I was inclined to agree.


    The real WTF is that you think an integer should be interpreted as a boolean...
  • uptaphunk 2008-09-05 12:30
    I don't know about you guys, but I'm looking forward to a post made by Top Cod3r.
  • RealLanguage 2008-09-05 12:33
    Satanicpuppy:
    Some of the conditional stuff I can see; you write it, you change it, you write it, you change it, you write it and FINALLY the data matches what it's supposed to and you don't recheck.

    Ah, the good old "coding by accident".

    W3C are currently working on version 2.0 which will include a true source of randomness, parallel universes and a doomsday machine.
  • SeanJA 2008-09-05 12:43
    twentyspaces is obviously a spacer (haha). When the need for more space between x and y, well... just add to twentyspaces instead of changing the variable names to match throughout the code, not really a wtf, more like laziness.

    On the other hand... never ever name your variables that way...
  • dgvid 2008-09-05 12:47
    The word "comparison" is being cleaned and restored. "Comparison" had become faded and dingy after decades of exposure to air pollution and sunlight. The word was moved outdoors for the 1926 World Fair in Wembley, England and had been unprotected from the elements since then.

    "Comparison" will be returned to the English language in April 2009. In the interim, the word "comparisment" is available as an alternative.
  • darkmage0707077 2008-09-05 12:57
    RealLanguage:
    Satanicpuppy:
    Some of the conditional stuff I can see; you write it, you change it, you write it, you change it, you write it and FINALLY the data matches what it's supposed to and you don't recheck.

    Ah, the good old "coding by accident".

    W3C are currently working on version 2.0 which will include a true source of randomness, parallel universes and a doomsday machine.


    Ah, cool! They're about to release a demo:

    http://en.wikipedia.org/wiki/Lhc
  • Max 2008-09-05 13:29
    Don't forget the usefulness of a non-integer base for your mathematics...
    After all, I know ALL the digits of Pi.

    ... in base Pi.
  • #define true false 2008-09-05 13:46
    snoofle:
    alex:
    #define false 1
    
    #define true 0
    Brought to you by the same folks who came up with FileNotFound?
    Definitely not. FileNotFound was a later enhancement by another developer.
  • Someone You Don't Know 2008-09-05 13:53
    Someone You Know:
    WhiskeyJack:
    Ah, someone beat me to it. Comparisment is a word now?
    And a perfectly cromulent one at that.
    That's brillig... err, I mean, brillant!
  • sf 2008-09-05 14:12
    Andy Goth:
    alex:
    #define false 1
    
    #define true 0
    #define ZERO -1
    Remember that? I took a second look at the code, and it turns out I was wrong. Here's how it actually reads:
    #define NEGATIVE_ONE 0

    In my opinion, the following would be much more straightforward and clear:

    #define ZERO true - false
    #define NEGATIVE_ONE true * false
  • Steve 2008-09-05 14:18
    RealLanguage:

    The real WTF is that you think an integer should be interpreted as a boolean...
    I don't. C does. And when in C, I do as C does.

    Okay?
  • Dan 2008-09-05 14:22
    Hope that helps:
    WhiskeyJack:
    Ah, someone beat me to it. Comparisment is a word now?
    http://www.comparisment.com/ is a registered domain, so the word must be in some dictionary somewhere!


    No, that doesn't follow. It just means more than one person made up a word. URL's do not have the same validity as a dictionary. If you were being sarcastanstic, I'm sorry that it missed me.
  • Andy Goth 2008-09-05 14:29
    sf:
    In my opinion, the following would be much more straightforward and clear:
    #define ZERO true - false
    
    #define NEGATIVE_ONE true * false
    int x = NEGATIVE_ONE * ZERO;
    
    int y = ZERO * NEGATIVE_ONE;
    printf("%d %d\n", x, y);
    will print -1 0. :^)
  • Richard 2008-09-05 14:34
    if (connected || !connected)
    {
    //ED: Snip
    }


    It also depends on the language. Many 4GL type languages designed for database work consider 'null' to be valid and treat it just as SQL does - so that could just be a really stupid way of saying:

    if (connected is not null) {
    // whatever
    }

    But yeah, its probably just stupid.

    TRWTF on the twentyspaces one (as well as COMMA for that matter) is people using variable (or constant) names that describe their initial state rather than their purpose. In these cases, FIELD_SEPARATOR would have made a lot more sense.
  • Someone You Know 2008-09-05 15:09
    Andy Goth:
    sf:
    In my opinion, the following would be much more straightforward and clear:
    #define ZERO true - false
    
    #define NEGATIVE_ONE true * false
    int x = NEGATIVE_ONE * ZERO;
    
    int y = ZERO * NEGATIVE_ONE;
    printf("%d %d\n", x, y);
    will print -1 0. :^)

    It's not how big it is...
  • Roney 2008-09-05 15:11
    Zap Brannigan:
    Thief^:
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.

    I also make all of my comparisons twice. It's the only way to be really really sure.


    I nuke my comparisons from orbit.
  • joemck 2008-09-05 15:14
    Andy Goth:
    Stephen Bayer:
    I was under the impression that bases needed to be whole numbers over 1.
    A number base (a.k.a. radix) does not need to be a whole number; that just makes it easier to work with. The Unix DC program (or at least the dc.sed version) supports fractional input and output radixes, via the 'i' and 'o' commands. Type 12.5;i;20;p; (replacing ; with newlines), and it'll print 25. Take the input number 20, expand it to 2*(12.5**1)+0*(12.5**0), and you get 25. If dc has a fractional output base, it's forced to spell out each "digit" as a decimal number, separating the "digits" with spaces. For example, 3.4;o;20;p; yields 1 1.6 3.0, since 1*(3.4**2)+1.6*(3.4**1)+3*(3.4**0) = 20.

    hmmm...

    arcanine:~ joemck$ dc
    12.5
    i
    20
    p
    24

    arcanine:~ joemck$ dc
    3.4
    o
    20
    p
    202

    BTW, this is in Mac OS X Leopard (based on BSD)
  • foo 2008-09-05 15:34
    RealLanguage:
    Steve:
    Regarding the final item, a number of years ago I had a discussion over a few Tsing Taos with some VMS weenies (er, hackers) about the proper values for true and false. Their contention was that since in VMS a return value of zero indicates success and any other value returned indicates failure of a function or operation, it makes sense that 1 (or any nonzero value) should be interpreted as false and only 0 be interpreted as true.

    They considered the C language's use of 0 as a false value to be a significant wart on the language.

    I can say that after many Tsing Taos and several servings of Kung Pao Death I was inclined to agree.


    The real WTF is that you think an integer should be interpreted as a boolean...


    That doesn't even come close to Perl, which has "0 but true" which is 0 when used as a number but true when used as a boolean. That's a WTF built into the language.
  • lokey 2008-09-05 15:42
    Zap Brannigan:
    Thief^:
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.

    I also make all of my comparisons twice. It's the only way to be really really sure.


    HI SANTA!
  • real_aardvark 2008-09-05 16:00
    Harrow:
    Steve:
    Regarding the final item, a number of years ago I had a discussion over a few Tsing Taos with some VMS weenies (er, hackers) about the proper values for true and false. Their contention was that since in VMS a return value of zero indicates success and any other value returned indicates failure of a function or operation, it makes sense that 1 (or any nonzero value) should be interpreted as false and only 0 be interpreted as true.

    They considered the C language's use of 0 as a false value to be a significant wart on the language.

    I can say that after many Tsing Taos and several servings of Kung Pao Death I was inclined to agree.

    I worked at DEC for years. I argued that the meaning of the argument returned from a VMS SVC function should answer the question "Did it fail?" and therefore zero is false and any nonzero is true. But VMS weenies were an alien breed, from a strange planet where mental effort is regarded as evil.

    -Harrow.
    Well, it's all quite interesting and historical, really.

    Language-wise, the "original" values for true and false were -- in BCPL, at least, and we're talking procedural rather than symbolic languages like LISP here -- 0 and -1, respectively. I suppose that only really makes sense with twos complement, and it depends upon whether you consider the rest state "true" or "false." But Martin Richards didn't half bang on about it. Me, I'd have chosen 0xdead and 0xbeef, thus leaving plenty of room for FileNotFound variants; but there you go. Why K&R chose to invert their legacy, I just don't know.

    OS-wise, I suppose it's down to your preferred variant of Multics descendant. Unix is, obviously, C, and thus true/false is pretty much a given. VMS (and possibly WinNT, by extension) is in a bit of a murky middle ground. Stratus VOS got round the whole thing by being PL/1 based, and not allowing return values from OS calls at all -- which made interoperability between languages a joy.

    I don't recall any problems arising from my writing multi-process debugging scripts in C for a COBOL application (yes, it could be done, and trivially), but then there's probably a bankrupt supermarket chain somewhere in Idaho that would disagree with me.
  • Shill 2008-09-05 16:08
    Kehvarl:
    Fiona:
    HUUUUUUUUURF


    It's a hippopotomus! It's not my cow!!


    Excellent reference, I declare you the winner. You may collect your prize at the door.
  • Dennis C. 2008-09-05 16:19
    #define false 1
    #define true 0

    Which is fine as long as the code you write refers to the two constants. Too much code however does not refer to them and just assumes that "true" equals 1.
  • Mog 2008-09-05 16:53
    Dennis C.:
    #define false 1
    #define true 0

    Which is fine as long as the code you write refers to the two constants. Too much code however does not refer to them and just assumes that "true" equals 1.


    Wow. Just as I thought comments on this site couldn't be more of a WTF.
    I really hope I did just miss your sarcasm.
  • North Bus 2008-09-05 16:56
    I don't know about you guys, but I can't wait for T0pCod3r to produce for us a production ready masterpiece consisting of selections from the above codez.

    *holds breath*
  • James 2008-09-05 18:14
    I was under the impression that bases needed to be whole numbers over 1.. ie. base 2, base 3, base 4, base 5, ... ok.. this could go on for a while.. i think there are a lot more whole numbers over 1. I used to use random bases when doing my fourth grade math homework, then argue with the teacher about the validity of my answers, calling her an idiot for not agreeing with me that 8 + 5 = 11


    Nah, you're not having real fun with math until you're doing all your work in base e.
  • James 2008-09-05 18:22
    Zap Brannigan:
    Thief^:
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.

    I also make all of my comparisons twice. It's the only way to be really really sure.


    What if there's a boolean tracking variable in the implementation of ==? Then you really need to make all your comparisons at least 3 times to be sure. I mean, why take chances?
  • Erzengel 2008-09-05 18:36
    Well, obviously:

    class SomeClass
    {
    private int ActualDblSpread = -2;
    public int DblSpread
    {
    get
    {
    ++ActualDblSpread;
    if(ActualDblSpread < 0) return 0;
    return ActualDblSpread;
    }
    }
    public void SomeMethod()
    {
    if((0 == DblSpread) || (0 == DblSpread))
    SwapGrid.GetCellRange(RowNumber, SwapGrid.Cols[ColDblSpread].Index).Clear(C1.Win.C1FlexGrid.ClearFlags.All);
    else
    {
    SwapGrid[RowNumber, ColDblSpread] = DblSpread;
    cr = SwapGrid.GetCellRange(RowNumber, SwapGrid.Cols[ColDblSpread].Index);
    cr.Style = StyleBidDblBoldSpread;
    }
    }
    }


    See? Makes sense, right? :-P

    (Note for you who don't have a sense of humor: JOKE. Merely demonstrates how the above code might possibly make some sense, even whilst being a WTF. Changing the value of a property in the get function? Eugh.)
  • lolwtf 2008-09-05 19:05
    One *possible* (but still stupid) reason for the first one is if the function does something nasty, and you don't want to risk that a dangling function pointer might fling you into it. Of course, it could just fling you to just inside the 'if' statement...

    "Everyone is an admin day" looks like some sort of sabotage. I sincerely hope the last one is too.

    And to save everyone the trouble, "twentyspaces" contains 25 spaces.

    (WTF is a comparisment anyway?)
  • Andy Goth 2008-09-05 21:04
    joemck:
    hmmm... BTW, this is in Mac OS X Leopard (based on BSD)
    Try this version of sed. You know what, try figuring out how it even works. :^)
  • Jeff Grigg 2008-09-05 23:20
    some coder:
    I found this in some production code:

    int iChkShut; // variables MUST be initialized, not sure why. Funny enough, the parameter iChkShut is used (uninitialized) for comparisment a couple of rows later.


    Holy bejesus that's funny


    I think I like your improvement to the comment. Management should give you a bonus for improving the program documentation. ;->
  • moz 2008-09-06 07:02
    foo:
    That doesn't even come close to Perl, which has "0 but true" which is 0 when used as a number but true when used as a boolean. That's a WTF built into the language.

    That's not a WTF, it's another way to do $[-1.

    "'0.0' == !'0.0'" is different, although I can't decide whether this is better or worse than PHP's "'0.0' > !'0.0' && 0.0<!0.0".
  • Jeff Grigg 2008-09-06 18:04
    #define COMMA "|"

    Richard:
    TRWTF on the twentyspaces one (as well as COMMA for that matter) is people using variable (or constant) names that describe their initial state rather than their purpose. In these cases, FIELD_SEPARATOR would have made a lot more sense.


    Another thought: It seems to have become standard industry practice to describe as "comma delimited values" *ALL* text files that use newlines to separate "records" and /any character at all/ to separate values on a line. So I fear that "COMMA" would appear to be a "sensible" name to a surprising number of our (possibly somewhat intellectually challenged) peers in this industry.

    (Personally, I agree with Richard: I would Refactor-Rename it to FIELD_SEPARATOR as soon as I noticed it.)
  • Jim 2008-09-07 06:17
    The C Programming Language, pp. 86-67:
    Since the imlementation of #define is a macro prepass, not part of the compiler proper, there are very few grammatical restrictions on what can be defined. For example, Algol fans can say

    #define then
    
    #define begin {
    #define end ;}
    and then write
    if ( i > 0 ) then
    
    begin
    a = 1;
    b = 2
    end


    Well, and there is an errata for the missing «;» ?
  • \ 2008-09-07 07:09
    Jim:
    The C Programming Language, pp. 86-67:
    Since the imlementation of #define is a macro prepass, not part of the compiler proper, there are very few grammatical restrictions on what can be defined. For example, Algol fans can say

    #define then
    
    #define begin {
    #define end ;}
    and then write
    if ( i > 0 ) then
    
    begin
    a = 1;
    b = 2
    end


    Well, and there is an errata for the missing «;» ?

    end is ";}".
  • Dekker3D 2008-09-07 14:04
    A Nonny Mouse:
    jimlangrunner:
    25th! (space)

    No, I didn't count. Had the computer do it for me.

    WTF?

    "twenty" is obviously base 12.5


    do people make jokes in base 12.5?
  • VxJasonxV 2008-09-07 17:06
    I think that last bit of code was the result of "morganj"'s upbringing.

    http://qdb.us/10958 (I would have linked to bash.org, but they're still down :( ).
  • Access boy 2008-09-08 00:49
    Niels:
        lSend = IIf(lSend = True, True, False)

    Obviously because there are other values than True and False. (FileNotFound etc.)

    In a real language I'd just have done lSend = !!lSend; for it, concise way to force a value to boolean.


    ROFL

    Since I use all 10 fingers to type, if I wanted to break the code by replacing it with something that looked almost the same I'd have used

    1Send = Not Not lSend
  • more randomer than you 2008-09-08 00:55
    Kuba:
    A Nonny Mouse:
    If .Fields("CUST_NUM") = "7742" Then
    dtmOrderPlaced = dtmOrderPlaced
    End If
    looks to me like someone needed a breakpoint while debuggering
    That's why I have always been at loss why some standard C header is not forced to include something to the effect of
    #define NOP() asm("nop");
    I have a header in my library of "useful stuff" that does include this. It is quite cross-platform, too!

    Cheers, Kuba


    kuba - unsw?
  • Roddy MacKenzie 2008-09-08 05:14
    I truly sympathise with Christophe Beugnet. I have seen the following pairs in different C headers .. in the same project! Much joy ensued as we tried to debug it.

    #define True 1
    #define False (!True)

    #define FALSE 0
    #define TRUE (!FALSE)

    #define false 1
    #define true (!false)

    Reminder for BASIC & Pascal programmers: C is case sensitive, so all six definitions were live at the same time.

    Yes, it was in code converted from Pascal to bad C by at least three Pascal programmers and an automated convertor (possibly "pastoc" or "pas2c")
  • dkf 2008-09-08 06:29
    Dekker3D:
    A Nonny Mouse:
    jimlangrunner:
    25th! (space)

    No, I didn't count. Had the computer do it for me.

    WTF?
    "twenty" is obviously base 12.5
    do people make jokes in base 12.5?
    Round here? Yes.
  • Tina Woodward 2008-09-08 17:35
    I just finished a Doom game and am about to start Duke Nukem 3D. The high res packs make these games look like brand new on new PC's.

    Jiff
    www.anonymize.us.tc
  • iToad 2008-09-08 18:14
    Thief^:
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.


    It's actually a bug. To cover both cases, the programmer meant to type:

    if((0 == DblSpread) || (DblSpread == 0))

    This covers both possible variants of the Boolean expression, and therefore is twice as likely to detect DblSpread being equal to zero, as using either term by itself.
  • someone 2008-09-08 20:09
    iToad:
    Thief^:
    andem:
    if((0 == DblSpread) || (0 == DblSpread))


    This comparison order is actually an old trick to avoid unintentional assignment in if() clause from the days when IDEs/compilers didn't warn about those. Constant = Variable assignment resulted in compiler error and saved some debugging time.

    That's not the wtf, the wtf is that it's exactly the same comparison twice.


    It's actually a bug. To cover both cases, the programmer meant to type:

    if((0 == DblSpread) || (DblSpread == 0))

    This covers both possible variants of the Boolean expression, and therefore is twice as likely to detect DblSpread being equal to zero, as using either term by itself.


    Just being pedantic:
    With operator overloading

    0 == DblSpread

    could return something different than

    DblSpread == 0

    (I love operator overloading.)
  • JS 2008-09-09 09:33
    Stephen Bayer:
    A Nonny Mouse:
    jimlangrunner:
    25th! (space)

    No, I didn't count. Had the computer do it for me.

    WTF?

    "twenty" is obviously base 12.5


    I was under the impression that bases needed to be whole numbers over 1.. ie. base 2, base 3, base 4, base 5, ... ok.. this could go on for a while.. i think there are a lot more whole numbers over 1. I used to use random bases when doing my fourth grade math homework, then argue with the teacher about the validity of my answers, calling her an idiot for not agreeing with me that 8 + 5 = 11


    Actually, not at all! At the university, I had the fun playing with things like these: http://en.wikipedia.org/wiki/Golden_ratio_base
    The golden ratio is just an example; you can use any irrational number, although algebraic integers are preferred as the give nice rules.
  • Fart Boss 2008-09-10 02:56
    private static final String MBS_PASSWORD = "f4rth9fe".toUpperCase();


    Fart
  • sribe 2008-09-10 11:31
    I was under the impression that bases needed to be whole numbers over 1..


    So... I guess you didn't get much further than 8th grade math! Ever here of e and natural logarithms and so forth???
  • Dave 2008-09-11 08:41
    I've seen the "confirmation" stuff used in safety-critical code, however having to pass a boolean for everything isn't very sound, usually you want to pass a unique access key of some kind to indicate "yes, I really did want to call scramReactor(), and didn't get up here just because of a fencepost error in the linker".
  • Chiper 2008-09-12 13:37
    lSend = IIf(lSend = True, True, False)

    This one actually makes a little bit of sense, given that VB is a loosely typed language. 'course, the more elegant solution is to just force cast it to a boolean. (VB can do that, right?)
  • �󲡱��� 2008-11-16 01:21
    ��̨�󲡱���,�󲡱���,����,������,�����󲡱���,�й���̨,�����󲡱���,�����������������󲡱�����Ϊ������������ṩ��,�����������ʵĴ�����Ʒ,Ϊ������Ҫ�������������ṩ������ȫ��λ����.�����´���롢�ɴ���롢���ʴ���������
    �������ߴ��ʿ��ص�ԴƵ�������й����걨���ʿ��ص�Դ�ܿ���ǿǿ���ֺ����Ĵ��ʿ��ص�ԴƵ�������ʿ��ص�Դ�ܿ�,���ʿ��ص�Դ�챨����Ϣ��Ŀ�����ɴ󺽺��r�� rmt�����й�רҵ���󺽺��r�� rmt�����վ��רҵ�Ĵ󺽺��r�� rmt��Ѷ���󺽺��r�� rmt��·�������󺽺��r�� rmtע������󺽺��r�� rmt��ҵ����¡��󺽺��r�� rmt���󺽺��r�� RMT��˾�ǹɷ�����ҵ���󺽺��r�� RMT��˾��Ҫ��Ӫ���ִ󺽺��r�� RMT,����ѹ�󺽺��r�� RMT,�˽�󺽺��r�� RMT��Ʒ����ʴ󺽺��r�� RMT���󺽺��r���ɥ����`����̳,�󺽺��r���ɥ����`���ɹ�,�󺽺��r���ɥ����`���ͺ�,�󺽺��r���ɥ����`������,��󺽺��r���ɥ����`��,��󺽺��r���ɥ����`��,�󺽺��r���ɥ����`������,�󹺴󺽺��r���ɥ����`��,�й��󺽺��r���ɥ����`��,�󺽺��r���ɥ����`����Ϣ
    �ؼ�����Ź���Ϊ���������Źǵ���Ҫ��Ź�������Դ �ؼ��ִ�Ź���Ϊ���������Ź��Ҳ�����Ź��г���Ʒ������Ϊ��Ź��г���˾�Ĵ�Ź��г���Ʒ�����������㼯ȫ����Ź��г����,��Ź��г���Ӧ�Ͳɹ���Ϣ
  • lotro account 2009-01-12 04:57
    ����lotro account��̳�����Ծ��lotro account��̳֮һ,�������ʵЧlotro accountƽ̨,רҵlotro account������,lotro account��Դ����lotro account�������ȵ�lotro account����������lotro account�Ż�������iPlus������lotro accountЧ��������ϵ���������lotro account������վ�����롣lotro account,������,lotro account��,�й�lotro account�Ż���վ���ṩlotro accounthttp://www.trade-accounts.com/buy-lotro/��lotro account�������棬lotro accounthttp://www.trade-accounts.com/buy-lotro/��ȫ������lotro account������louis vuitton��������louis vuitton��˾;louis vuitton��ƹ�˾�����ݻ���louis vuitton������louis vuittonӡˢ���Ͼ��ձ�Lv bags ���� �� �������Lv bags ���� �� �����̱�Lv bags ���� �� �����̱�Lv bags ���� �� ��ĩ��Lv bags ���� ����Maple Story MesosӰ��Maple Story Mesosý�����ý�巢��Maple Story Mesos����Maple Story Mesos����Maple Story Mesos�߻���ֽMaple Story Mesosý�屨��ý��Marble Bathtub��������Marble Bathtub�������ݵ�Marble Bathtub��ʽ����ʽ����ǰ5���������ύMarble Bathtub���й�Marble Bathtub���ṩ�г�Marble Bathtub��ƴ��⡣�й���massage beijing���й�massage beijing��ģ�أ�massage beijing�߻�,massage beijingý�壬massage beijing��˾��massage beijing����
  • huojia 2009-03-02 00:53
    &nbsp;&nbsp;
    货架racking.&nbsp;&nbsp; 仓储货架
    南京货架设备要产品包括:重型货架
    ,阁楼货架,超市Shelf,重量型货架,横梁式货架,驶入式货架... 仓储笼
    货架的形式与材料 · 立体仓库 · 货架厂
    物流规划设计的步骤与程序(货架的设计... 中国物流行业呈现三足鼎立抢市场 · 亚洲第三方物流的现状和发展 ... 托盘
    抽出式货架系列 · 重力式 货架/推入式货架钢托盘
    移动式货架 · 阁楼式货架 · 悬臂式货架
    系列 长件物料储存货架&nbsp;货架公司
  • ϳ�߻� 2009-05-15 17:30
    CTIN̨��ϳ�߻������ṩ̨��ϳ�߻������ϳ�߻�����ͼƬ�г���Ѷ����,���ṩ������ϳ�߻��г���۹��г�ϸ����ǰ������ ��˾-���������ϸ����ǰ������ ��˾���׶�����׿����ϸ����ǰ������ ��˾,��ϸ����ǰ������ ��˾�ṩ50������ֵ�ϸ����ǰ������ ����.�����°�������ҵ,�°�������ز�ҵ���°������ܱ߲�Ʒ,����רע�°�����,��ӭ���Ͽͻ�.
    �������Ż��������������Ż����ð���,�ṩ�������Ż���ָ�ϣ����Ż��꾭����·�����Ż����⳵���Ƶ�Ԥ�������Ż�����ʳ�����Ż����ͼ�ȷ���.�ؼ����ʻ���Ϊ���������ʻ�����Ҫ�ʻ�������Դ �ؼ����ʻ���Ϊ���������ʻ��й���ʾ����Ʒ��Ϊ��ʾ����������ҵ��λרҵ������ʾ�����ྭ��ʵ�á�������������ʾ����Ʒ��������Ʒ����ʾ����ƷȤ;��΢�����������й�������΢������������վ������һ������΢����������Ӫ��ƽ̨--Ȥ;��΢�����������������ḻ����΢��������Ѷ����΢���������������ȫ���������΢�������˴���΢���Ϻ�, ������΢���Ϻ�������, ʱ��֮����, ������΢���Ϻ�������, ����ɽ��΢���Ϻ�����, �й���΢���Ϻ���������, �Ĵ���΢���Ϻ���