- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Shouldn't it be "#define Begin {" instead?
Admin
I wonder if the guy was a Delphi programmer that had a hard time getting out of his comfort zone?
Admin
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 ;)
Admin
I wonder if he also did:
#define <> !=
Admin
Isn't this the "joy" style of programming that's used on the *nix SH utility?
Admin
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
Admin
Didn't Stroustrup suggest using exactly that "technique" in C++PL for people migrating from Pascal to C?
Admin
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"
Admin
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
Admin
Too bad his do nothing If had an else block. I always enjoy a good if block that really does do nothing.
Admin
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?
Admin
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
Admin
Now i know how other languages were evolved from C
Admin
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...
Admin
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
Admin
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.
Admin
Admin
#define color colour
Admin
Aren't static and shared OPPOSITES?