Re: Malcolm's new book - Chapter 1 review
- From: "Peter J. Holzer" <hjp-usenet2@xxxxxx>
- Date: Sun, 12 Aug 2007 12:38:11 +0200
On 2007-08-11 05:30, Malcolm McLean <regniztar@xxxxxxxxxxxxxx> wrote:
"Eric Sosman" <Eric.Sosman@xxxxxxx> wrote in message
news:1186694915.312161@xxxxxxxxxxx
Good! At a stroke, you've cured three of the bugsThe standard says that a char argument to isspace() is illegal. That's
I spotted in your first chapter -- not by fixing them,
but by blaming them on the Standard. Bravo! Your book
gets better and better with each new finger-pointing!
clearly quite unacceptable.
I could have mentioned the issue, but it gives the impression that C is a
very difficult, almost unusable language. maybe legitimately, because the
committee is pushing it in that direction.
In fact it is so unlikely that the reader will use a system that does break
on char arguments,
Unlikely? On all compilers I've used except one the default char type
was signed (most had a switch to make it unsigned). On all systems I've
used since ca. 1990 the default character set included characters with
the high bit set. So on almost all systems I've used in the last 17
years the code
char *s;
...
while (*s) {
if (isspace(*s)) {
do_something();
}
}
would fail. It had to be
char *s;
...
while (*s) {
if (isspace((unsigned char)*s)) {
do_something();
}
}
Of course these days the assumption that 1 char is 1 character is often
wrong, so you'd have to use the wide- or multibyte-character
equivalents.
and because the standrad is so absurd, I thought it best
simply to sweep the matter under the carpet.
You are certainly entitled to your opinion that C is an absurd language.
So use a different language in your book. You can even use a language
which differs only a little from C. But if you do that, don't claim that
you are using "ANSI C", because you don't.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@xxxxxx |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
.
- References:
- Re: Malcolm's new book
- From: Kelsey Bjarnason
- Re: Malcolm's new book
- From: Malcolm McLean
- Re: Malcolm's new book
- From: Kelsey Bjarnason
- Re: Malcolm's new book
- From: Malcolm McLean
- Re: Malcolm's new book
- From: Kelsey Bjarnason
- Re: Malcolm's new book
- From: Richard Heathfield
- Re: Malcolm's new book
- From: Kelsey Bjarnason
- Re: Malcolm's new book
- From: Malcolm McLean
- Re: Malcolm's new book - Chapter 1 review
- From: Eric Sosman
- Re: Malcolm's new book - Chapter 1 review
- From: Malcolm McLean
- Re: Malcolm's new book - Chapter 1 review
- From: Kelsey Bjarnason
- Re: Malcolm's new book - Chapter 1 review
- From: Mark McIntyre
- Re: Malcolm's new book - Chapter 1 review
- From: Kelsey Bjarnason
- Re: Malcolm's new book - Chapter 1 review
- From: Malcolm McLean
- Re: Malcolm's new book - Chapter 1 review
- From: Eric Sosman
- Re: Malcolm's new book - Chapter 1 review
- From: Malcolm McLean
- Re: Malcolm's new book
- Prev by Date: Re: a new C/C++ type that when overflow i see it
- Next by Date: Re: Malcolm's new book - Chapter 1 review
- Previous by thread: Re: Malcolm's new book - Chapter 1 review
- Next by thread: Re: Malcolm's new book - Chapter 1 review
- Index(es):
Relevant Pages
|