Comment On Stupid Curly Braces

As programmers, I think we all have our own unique way of doing things. I prefer having spaces between assignemnts (e.g. “dooDah = 28” instead of “dooDah=28”). I like having a variable declaration and initialization on the same line. I like indentation. And to be honest, I really am not a big fan of the whole curly brace semi-colon thing. So immagine my delight when  Barry Etter showed me what a C contractor did to all the code he was assigned to: [expand full text]
« PrevPage 1Next »

re: Stupid Curly Braces

2004-06-14 16:31 • by Ken
Shouldn't it be "#define Begin {" instead?

RE: Stupid Curly Braces

2004-06-14 16:31 • by Ryan Farley
I wonder if the guy was a Delphi programmer that had a hard time getting out of his comfort zone?

re: Stupid Curly Braces

2004-06-14 18:40 • by Lucas
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 ;)

re: Stupid Curly Braces

2004-06-14 20:28 • by Mike Dunn
I wonder if he also did:
#define <> !=

re: Stupid Curly Braces

2004-06-14 21:15 • by Larry Osterman
Isn't this the "joy" style of programming that's used on the *nix SH utility?

re: Stupid Curly Braces

2004-06-14 21:29 • by Steve Maine
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

re: Stupid Curly Braces

2004-06-15 04:31 • by Ian Darling
Didn't Stroustrup suggest using exactly that "technique" in C++PL for people migrating from Pascal to C?

re: Stupid Curly Braces

2004-06-15 07:38 • by Barry Etter
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"

RE: Stupid Curly Braces

2004-06-15 08:29 • by dturini@rtsistemas.com.br (Daniel Turini)
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

re: Stupid Curly Braces

2004-06-15 11:10 • by Q
Too bad his do nothing If had an else block. I always enjoy a good if block that really does do nothing.

re: Stupid Curly Braces

2004-06-15 15:55 • by Trey Hutcheson
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?

re: Stupid Curly Braces

2004-06-16 13:02 • by Andy
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

re: Stupid Curly Braces

2004-06-24 13:05 • by Prakash Nadar
Now i know how other languages were evolved from C

re: Stupid Curly Braces

2004-08-12 09:01 • by KoFFiE
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...

Re: Stupid Curly Braces

2006-08-26 02:08 • by mep

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


 

Re: Stupid Curly Braces

2008-07-03 02:56 • by 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.

Re: Stupid Curly Braces

2009-08-22 14:32 • by zennehoy (unregistered)
283087 in reply to 88283
mep:

#define end }

hehe, that would work wonders with iterators :)
« PrevPage 1Next »

Add Comment