Re: The annotated annotated annotated C standard
- From: "Clive D. W. Feather" <clive@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 21 Jan 2008 09:15:20 +0000
In article <eMmdnXnS_8oAaQ_anZ2dnUVZ8t-nnZ2d@xxxxxx>, Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes
This was the case in out of date languages. It is no longer the case.
In fact, a runtime error produced by a bounds checker is preferable to
"undefined behavior", as is INF or a similar symbol.
Whether this is preferable depends very much on the situation.
Furthermore, nothing in the C Standard forbids it. I've certainly used bounds-checking C compilers.
Doug Gwyn once said that "UNIX was not designed to stop you from doing
stupid things, because that would also stop you from doing clever things."
Very much the same idea applies to C. Yes, some modern languages are
sand-boxes in which you can't break anything no matter how hard you try,
but this is at the expense of limiting your horizons to things which, at
some level, the language designers envisaged when they decided what to
allow and what to disallow.
ISO C doesn't impose such limits. It draws a line around the abstract
machine and says, effectively, "in here, we can make some promises about
program behaviour - but if you step across the line, you're out of the box
and you're on your own".
Exactly. Some of us no longer feel the psychological need to be constrained by the sandboxes. Perhaps Nilges still does.
Or, come to think of it, at college the assembler fans used to refer to those sorts of languages as "Bondage and Discipline languages". Perhaps that says something about him.
[Or perhaps not. But if he can impugn my motives, why can't I impugn his?]
Actually, I've used both "loose control" languages like C and "tight control" languages like Algol. Each has its place.
Basic with the structured programming additions happens to be superiorIf what you say about BASIC's for loop is correct (and I am not about to
to C. It evaluates the for limit once and doesn't allow stupid
cleverness.
take your word for it), this makes BASIC's for loop less flexible than
that of C. Full evaluation of the termination condition each time through
the loop is a powerful construct if used properly.
And a dangerous one in others. The correct answer is to realize that both approaches have advantages and disadvantages. Either is a reasonable choice for a language designer to make.
Algol 60 sometimes pre-evaluated and sometimes didn't, depending on the exact notation used. Algol 68 pre-evaluated three of the bounds of a loop but not the fourth.
--
Clive D.W. Feather | Home: <clive@xxxxxxxxxx>
Tel: +44 20 8495 6138 (work) | Web: <http://www.davros.org>
Fax: +44 870 051 9937 | Work: <clive@xxxxxxxxx>
Please reply to the Reply-To address, which is: <clive@xxxxxxxxxx>
.
- References:
- The annotated annotated annotated C standard
- From: spinoza1111
- Re: The annotated annotated annotated C standard
- From: Clive D. W. Feather
- Re: The annotated annotated annotated C standard
- From: spinoza1111
- Re: The annotated annotated annotated C standard
- From: Stephen Howe
- Re: The annotated annotated annotated C standard
- From: spinoza1111
- Re: The annotated annotated annotated C standard
- From: Richard Heathfield
- The annotated annotated annotated C standard
- Prev by Date: Re: The annotated annotated annotated C standard part 4
- Next by Date: Re: Sequence points
- Previous by thread: Re: The annotated annotated annotated C standard
- Next by thread: Re: The annotated annotated annotated C standard
- Index(es):
Relevant Pages
|