- 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
Many programming languages begin as frontends to existing languages and if the language already supports some form of substitution then the tasks is significantly easier. I used the following definitions when I moved from Pascal to C:
#define begin {
#define end }
Then I incorporated it into my winning IOCCC entry: http://www.ioccc.org/1996/gandalf.c
Hey, at least I knew it was bad practice.
Admin
Admin
Wrong, wrong, wrong! "Forever" is spelled for(;;). Yes, I prefer the version with no space. (Some versions of GCC compare 1 to 0 if you use while(1) with no optimisations.)
That said, it seems like he was trying to make C more like his favourite language, whatever that may be. While we're at it,
#define begin {
#define end }
Admin
Ever.
Admin
Just wanted to get the 256 posts.
What to i win??
Admin
Actually, based on the header provided the correct syntax is:
repeat {
...
} forever;
I started with BDS C in the late 70s. It included the defines:
#define BEGIN {
#define END }
by default. Bloody Pascal programmers :-(
Since then I have come across:
#define FOREVER for(;;)
far too often, most conspicuously in Borland C. The argument goes: you can easily miss the ;;, but FOREVER stands out. Yeah, whatever.
I develop and maintain embedded code. After many years of doing so I have come to a simple conclusion: the syntax is defined by the standard. Anything else is wrong because the maintainers will invariably be adversely affected by the 'better' syntax.
Don't forget the maintenance phase is by far the longest phase for any software project - that's where you want any cost minimisation to occur.
Admin
Admin
Now the maintainer has to re-interpret every "repeat { ... }untilforever" in the code into something that the rest of the C-speaking world understands without depending on kooky precompiler tricks.
Yes, that would be confusing. What could "repeat until forever" possibly do?
Admin
With today's debuggers, you can put a conditional breakpoint on the condition.
Yes, I've written code like
if (x < 0) { neg = 1; } else { neg = 0; }
but this was in the olden days. Go with your tools.
P.S. No need to shout.
Admin
What no: #define then { #define end }
Admin
I actually really like the until and unless.
Addendum 2017-01-26 08:26: I wouldn't do it myself in C (and certainly not in a shared project), but I do wish languages actually had those constructs built in.