Don’t try to play the “look how big mine is” game; there’s usually someone
whose list IS bigger than yours.
K&R was a bad book, incoherent for its time, and it never improved. Most of
us in the 1970s learned C in spite of it, rather than because of it. It
gave no formal specification of what things did, but worked mostly by
example.
This was good, because the language was so bad that you couldn’t actually
say what it would do in many circumstances.
I once worked for a company that had to produce a C compiler that was
bug-for-bug compatible with K&R C, that is, it couldn’t compile correct
code, it had to compile erroneous code so that existing programs would still
run because the programmers depended upon the erroneous behavior. I also
once worked for an organization that supported over 30 versions of Unix, and
we were constrained to write in SUBSET of K&R C because some compilers
wouldn’t compile the construct, or would compile it erroneously, or compile
it differently (because there were two or more ways to interpret what was
meant by the construct, and nobody could agree which one should be used).
Personally, I never really believed that a 30-year-old book that describes a
language implemention on a machine that no longer exists, and has not
existed for decades, is a valid approach to building software. Maybe this
is a bit weird, but I *like* the idea of type-checking prototypes, of
well-defined and agreed-upon semantics for not only the language but the
libraries, and so on.
What’s Ada got to do with anything? It took vendors longer than that to get
C working on multiple platforms. Most of them never succeeded, but went out
of business, abandoning their compilers and users. Having watched any
number of people have to transition from MIPS, Alpha, Apollo, and other
vendors, it is clear that none of those early compilers ever worked right.
joe
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David Craig
Sent: Friday, December 19, 2008 12:20 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] debug vs release builds
K&R C is dead, and what is legal or not legal in it is of no consequence.
Since I am an ‘experienced’ developer I will add my $0.02 to this statement:
“Over my dead body”. I like K&R and still use my copy as a reference though
I don’t care for their brace placements. I know that anything I write using
K&R will compile with the compilers I have to use - Microsoft WDK and Visual
Studio. Microsoft doesn’t care about the ANSI C standard and doesn’t
support it. I would prefer to be able to define a loop control in the
initializer of a for statement, but it doesn’t work in my environment. We
write an in-box driver and stay with ‘C’ as Microsoft seems to prefer.
Also PC-Lint from Gimpel will flag all usage of do {} while(0/1/TRUE/FALSE).
It will also flag the while(1/TRUE) usage too.
I have programmed on the Honeywell 201, IBM ANFSQ7, Burroughs 3500/4700,
Sperry 1100/60, CP/M on Z80/8080, and various languages including assembly,
Pascal, Cobol, C, and C++ (maybe a few more, long ago forgotten). I do some
Python where indicated, but I generally try to avoid user mode.
I see your objection in that their choices were made because of the
limitations of compiler technology on the systems being used. It took
compiler vendors over a decade to get Ada fully working on many platforms.
However, my objections to ANSI C99 stands because the only vendor remaining
in my world just doesn’t support it.
“Joseph M. Newcomer” wrote in message
news:xxxxx@ntdev…
> K&R C is dead, and what is legal or not legal in it is of no consequence.
>
> The reason the K&R compilers favored for(; instead of while(TRUE)
> was the compiler was so mind-bogglingly stupid that it wouldn’t
> optimize
> while(TRUE)
> into an infinite loop; the code really was
>
> test:
> mov r0, 1
> je exitloop
> …loop
> jmp test
> exitloop:
>
> So the for(; construct was used because of the hopeless inadequacy
> of the compiler.
>
> Any self-respecting compiler that sees
>
> while(FALSE)
> {
> }
> would generate the following code for the body of the loop:
>
> which is what should happen. Basing design decisions on bad compilers
> for obsolete languages is never a good strategy.
>
> [I started programming in C in 1975 on the PDP-11, having spent much <br>> of my previous time using real optimizing compilers that actually <br>> generated good code. I was completely apalled at the code quality of <br>> the original K&R compiler] joe
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of David Craig
> Sent: Thursday, December 18, 2008 9:05 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] debug vs release builds
>
> A pet peeve of mine is those who use the while(0) or even while(1) to
> end do loops. The only legal K&R method of having an infinite loop
> construct is by using for( ; ; ) {}; with a break statement where
> needed to get out. If you make the break; the last statement before
> the closing bracket, it becomes a
> while(0) terminator. It will not cause an error/warning with any
> compiler I have seen or even the latest PC-Lint since K&R specifically
> states that the three parts of the ‘for’ are optional.
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
>> I thought do {} while (0); was to allow you to break out of a block
>> of statements without using goto.
>
> Not only.
>
> do { … } while(0) is the usual way of writing the right-side of the
> function-like macro, so that extra semicolon (which can inlfluence the
> semantics) will not be added as expansion.
>
> Actually, if you use #define to write an inline function, its body
> should be wrapped by do { … } while(0)
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> –
> This message has been scanned for viruses and dangerous content by
> MailScanner, and is believed to be clean.
>
>
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
–
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.