• Ken (unregistered)

    Shouldn't it be "#define Begin {" instead?

  • Ryan Farley (unregistered)

    I wonder if the guy was a Delphi programmer that had a hard time getting out of his comfort zone?

  • Lucas (unregistered)

    oooh! right there is a great programming practice we should all follow:

    if( s == NULL)
    { ; /* do nothing */ }
    else
    { ... ... }

    i never liked using the != operator myself ;)

  • Mike Dunn (unregistered)

    I wonder if he also did:
    #define <> !=

  • Larry Osterman (unregistered)

    Isn't this the "joy" style of programming that's used on the *nix SH utility?

  • Steve Maine (unregistered)

    This post reminded me of an entry in the 2000 International Obfuscated C Contest:

    http://www.ioccc.org/2000/primenum.c

    What's funny about this one is that its actual function is totally different than its apparent meaning. Here's the spoiler, if you get bored unwinding all those #defines...

    http://www.ioccc.org/2000/primenum.hint

  • Ian Darling (unregistered)

    Didn't Stroustrup suggest using exactly that "technique" in C++PL for people migrating from Pascal to C?

  • Barry Etter (unregistered)

    Good catch, Ken. It should be "#define Begin {". I was in a hurry.

    How about putting "#define { Begin" at the top of your code and trying to compile? That would be loads of fun trying to resolve the compile error:

    "Found 'Begin'. Expecting '{; function, blah, blah"

  • dturini@rtsistemas.com.br (Daniel Turini) (unregistered)

    Bonus points for the
    if (s == NULL)
    Begin
    ; /* do nothing */
    End
    else

    He actually could done it better if he created:
    #define DO_NOTHING ;

    if (s == NULL)
    Begin
    DO_NOTHING
    End
    else

  • Q (unregistered)

    Too bad his do nothing If had an else block. I always enjoy a good if block that really does do nothing.

  • Trey Hutcheson (unregistered)

    My company has a legacy VB6 app ( ported from VB3, previously Vb1 dos , previously quickbasic... ) that has a const defined like so:

    Global Const ONE As Integer = 1

    So, all the for loops and other constructs use it as such:
    For i = ONE To bla bla bla

    or
    If someValue = ONE Then bla bla bla

    why?

  • Andy (unregistered)

    Not that ONE = 1 is good, or even maintaining code that has been ported through so many interations is good... but....
    It could be that 1 and l were often confused by the original developer. To clarify he dictated that 1 = ONE and therefore wouldn't confuse a variable l with a number 1....
    The things people do....
    -A

  • Prakash Nadar (unregistered)

    Now i know how other languages were evolved from C

  • KoFFiE (unregistered)

    This must be the worst practice ever in C :-/
    The curly braces are so... curly and nice...
    Don't understand how people can work with the stupid begin/end things - how the f*ck do you jump from the beginning of a block to the end - or vice-versa without losing precious time? In vi(m) I just press shift-5 and my cursor is at the matching bracket. In Textpad this is Ctrl-M - and any self-respecting editor has such a feature...

  • mep (unregistered)

    wow, i'm a dork, commenting on such an old post.  I actually send in a submission, but it was basically the same as this one.  At a company I used to work for, this "programmer" we affectionately called 2pac (why you might ask?  because his buddy that already worked at the company got him the job, and his name was pocket boy because he always had his hands in his pockets, so this new "programmer" came to be known as pocket boy 2, 2pac, or tupac), had a file called ctweaks.h which stuff like:

    #define Begin {

    #define end }

    etc, etc, etc

     

  • Tom (unregistered)

    I actually think this makes a lot of sense if you're not comfortable with certain aspects of syntax. To be fair to other programmers, you should return it to normal once you're finished.

    Here's the three steps; Create a header with your particular keyword changes you desire. Create a regex set to change the files to your settings. Create a regex to return the files to standard afterwards.

    The major problem would be if someone had used one of your personal words in the code you're working with. I mean, if someone's defined a "Begin" variable, you might not even notice till the program bugged up.

  • zennehoy (unregistered) in reply to mep
    mep:
    #define end }
    hehe, that would work wonders with iterators :)
  • MOtte (unregistered)

    #define color colour

  • Anonymous (unregistered)

    Aren't static and shared OPPOSITES?

Leave a comment on “Stupid Curly Braces”

Log In or post as a guest

Replying to comment #:

« Return to Article