• NH (unregistered) in reply to Flipper
    Flipper:
    Raw:
    I've seen that problem happen occasionally in some older VB version (probably VB4, it was buggy as hell). I never managed to figure out the logic behind it, but it certainly did happen, and the solution was to put an empty Else clause.

    So, there is a WTF, but it's not the programmer, it's Microsoft.

    No, the WTF is the programmer, who has heard at least 17,000 times that Microsoft == WTF^WTF^2, but continues to use it. And some don't even stop there, working hard to staunchly defend the sloppiest crud in the known universe.

    It has unfortunately been all too common with compiler bugs like that, so I won't say that a defensive programming action is a WTF. The only WTF is the compiler that required that kind of programming once.

    And since code like that doesn't do anything neither harmful nor harmless it's not a priority to clean it out.

    I'm even wondering why this made the WTF blog.

  • (cs) in reply to London Developer
    London Developer:
    sponk:
    That's a bit of a mild wtf. Someone isn't very good at programming. Oh no. At least they tried to figure out and fix whatever was going wrong, even if they didn't understand it.

    Yes, so lets just sell it as commercial software, shall we???? AWFUL!!! In most companies I worked for this would have been a sackable offence!!!

    What would be the sackable offence? Running into a compiler bug and finding a workaround? Or leaving a comment explaining the workaround?

  • NOPIK (unregistered)

    Short IF ... THEN form leaks stack. And VB doesn't report overflow, when it caused by "nested" operators or parentnesses. So, when you put ELSE, you will "close" several IFs up. To avoid this bug, every IF must have ENDIF (compiler will check stack overflow before ENDIF)

  • Tintazul (unregistered)

    Ohh, skipping the End If! What would they do if they were progamming in Python to prevent the program exection from "skipping the lack of indentation in following line"? Sheesh.

  • (cs) in reply to Tintazul
    Tintazul:
    Ohh, skipping the End If! What would they do if they were progamming in Python to prevent the program exection from "skipping the lack of indentation in following line"? Sheesh.

    Presumably there would be no possible workaround if the Python interpreter had a bug like this, so they'd just not use Python.

  • Stephen (unregistered) in reply to SomeGuy
    SomeGuy:
    Raw:
    Unless you have a way overdue deadline. Then you just ship it and check it out later.

    How often does checking it out later actually happen?

    I'd say 99.99% of the uptime. I mean time. I've been way behind and tried to cut corners in testing and figuring these things out, and almost always had to revisit the situation due to bug reports coming in just after the publishment.

  • niemo (unregistered)

    I've seen the VS 2005 debugger skip over End If, if End If is the last line in a method. The code is otherwise executing fine (as well as an "End If" statement can be executed), it's just a flaw in the debugger. This guy was probably watching the debugger and thought that the line of code was being "skipped".

  • aliquot (unregistered) in reply to snoofle

    I guess you didn't know there is syntax highlighting in vi / vim - here's the first google result for an example

    http://www.cyberciti.biz/faq/turn-on-or-off-color-syntax-highlighting-in-vi-or-vim/

    I have done plenty of coding in vim with syntax highlighting :)

    Or maybe it was SO LONG AGO that you were using a vt100 with a monochrome display, and using "screen" to shift between your vi and debugger "windows" ? ;-)

    captcha: "dolor", suitable comment on going back to vi + debugger after using an ide!

  • Tim williscroft (unregistered)

    Once upon a time I ran into a very similarly weird bug in the VMS C compiler.

    I had an extra semicolon between declarations.

    The next FOR loop in the program had the semicolon as it's block. The block following was executed just once.

    University assignment. I Did work it: after submitting the (not working, with a complaint) assignment.

  • kc (unregistered) in reply to snoofle

    I prefer to style my comments like this:

    	int x = 1;
    	/*++++++++++++++++++++++++++++++++++++++++++++++++++++++\
    	 ++x;/* This is a long comment of a lot of text that   * \
    	 ++x;/* had absolutely no redeeming value except that   * \
    	 ++x;/* it could easily mislead you into making           */
    	 ++x;/* your eye skip right past the relevant part in   * /
    	 ++x;/* the middle of the block of unending comments.  * /
    	   ++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    
  • Still Not Tim (unregistered)

    On the subject of syntax colouring:

    I'm sure I'm not the only one to have experienced the following, when coding in an IDE featuring auto syntax colouring:

    Someone loudly and repeatedly proclaiming that I was "not a real programmer" because I was "wasting time colouring in the letters." o_o

  • shftw (unregistered) in reply to snoofle

    Syntax highlight FTW?

  • anonymous (unregistered) in reply to Leak
    Leak:
    Old fart:
    It may be related to a known bug in VB6 that occurs if an in-line If statement is nested in an If / End If block, e.g.:

    If blnCondition1 then If blnCondition2 then (do something here on this line Else (do something else here) End If

    The nested If must be accompanied with a corresponding End If to avoid the bug. Don't know how this got past the QA when VB6 was released

    That looks more like a dangling else to me...
    A dangling Else shouldn't be possible in BASIC. Both of the methods listed in the Wikipedia article are in play. The single-line version is not ambiguous because the behavior is supposed to be defined. The multi-line version has End If to avoid ambiguity. Ne'er the two shall meet; unholy marriages of the two shouldn't even be syntactically valid:
    If A Then something
    Else elsething

    should result in a syntax error (Else without If).

    As far as the syntax of single-line statements is concerned, Else always applies to the nearest If. For instance:

    If A Then If B Then something Else elsething
    If A Then If B Then something Else Else elsething

    These are logically different, and should be parsed as follows:

    If A Then (If B Then something Else elsething) Else nothing
    If A Then (If B Then something Else nothing) Else elsething

    The single-line version is supposed to be restricted to a single line, and should always end at the end of it. The next line should under no circumstances be parsed as a continuation of it unless the line continuation operator is used to specifically indicate that it should.

Leave a comment on “Illogical Logic Flow”

Log In or post as a guest

Replying to comment #:

« Return to Article