spinoza1111 said:
The problem is that C's "standardised formality" is bought by
simultaneously calling things undefined and permitting vendors to
continue to support the "undefined" concepts. C is simply not
formalized save in the most "Platonist" sense as opposed to the
"Intuitionist" sense, where Platonism in the philosophy of mathematics
is the belief that mathematical objects exist *in reality* whether or
not we know them, whereas Intuitionism is the belief that it doesn't
exist until it's constructed.
Now, it would seem that Intuitionism would be the philosophy of the
competent programmer.
I guess that there is an issue of context, as I suggested elsewhere.
If you want to use C within one context (one where you treat the
behaviour of a particular implementation as being the de-facto
definition of "C" - which may not be an unreasonable approach, depending
on the situation), you view it one way. If you want any chance of
writing something that will behave in a predictable way in a different
environment (different compiler/OS/whatever) or when underlying
assumptions change (word sizes changing on your platform, for example),
you take a different view.
I accept that you take the view that there is no such thing as
portability when it comes to C. (I'd also agree that if you take the
first approach, you're right.)
[And at this point let me mention my sadness on hearing that Dik
Winter has passed away, for this type of statement is what he loved to
jump on: perhaps as a Dutch person he felt a special connection with
Intuitionism, and he always had something interesting to contribute to
the discussion, especially when I mentioned Brouwer or Dijkstra.]
Applying this to programming, to say "doing arithmetic on a void
pointer has no result" is Platonic since Adler showed (constructively
and in an intuitive/Intuitionist way) how this has a sensible meaning:
the sizeof a void pointer is the sizeof the smallest unit of memory.
It is Platonist to insist on the (unconstructed) possibility of an
alternative interpretation.
Clearly, doing arithmetic on a void pointer produces a result, but
whether it's useful or reliable is a different issue.
Read Fowler/Burchfield Modern English Usage. Fowler makes no attempt
whatsoever to legislate what English should be, only what literate
people do. For example, Burchfield usefully notes that UK speakers
have FINALLY (as of the latest edition) given us an English
"construct" that is sorely needed: a reflexive pronoun that means
"himself or herself". "Themself" has been spotted by Burchfield:
"someone has hurt themself". Likewise, Adler's idiom makes perfect
sense.
Sure - I've read Fowler, though it's a few years since I picked it up.
It describes some ways that people use English, with the recognition
that natural language evolves and changes. Indeed, in the case of
English, there is a good bit of parallel development because of the
number of large, but geographically separated, first-language users of
English.
But I'm still not convinced that we should try to map between languages
for humans and languages for machines in quite this way at this stage in
language development.
Your last statement is literally untrue in most cases, in C. There is
no runtime check, and there are cases of code that dereferences "bad"
pointers and gets away with it,.
Yes, it is true that you can often get away with all sorts of things.
If, however, you read it in conjunction with the paragraphs just above,
you see the problem; you might get away with it today, tomorrow or the
next decade. When the situation changes (word sizes, pointer handling,
whatever), your code suddenly doesn't work as you intended (and how it
had been behaving) and the vendor may or may not feel that it's there
responsibility to reproduce the old (but undocumented) behaviour in
newer iterations of the compiler.
Sticking to behaviours that are documented should avoid these problems.
All very true but irrevelant to Adler's (Intuitionist) point: that one
test of a construct is whether we can construct a working runtime
model.
Fair enough - but the delivery the right output isn't a good basis on
which to judge the correctness/appropriateness of the inputs or the
process applied. Language features shouldn't be black boxes.
Whereas an earlier generation of C programmers (myself included)
graduated into C (and out of it in my case when I realized its
limitations) from assembler, many posters here started with C and may
have been crippled by it to the extent that they assault authors like
Schildt for speaking of stacks and heaps.
I would agree that there are people who have not experience a
wide-enough range of language-types and have tunnel-vision on the
"right" way to do things based on a narrow definition of "right"ness.
I haven't read Schildt (so I can't and won't comment on him), but I have
found it to be the case in a fair number of other language guides and
references. I have particular experience of this in C++* where the
quality of the commentary varied wildly, and the language was often
misrepresented -- not that C++ doesn't have lots of things to dislike in
any case. ;-)
Where authors present concepts or actual code which mislead readers
about norms within the language standards (without acknowledging that
fact), I have problems with it - and that includes cases where it has
been done to assist the beginner. If we believe a feature is wrong, we
should say so up front. If we choose to simplify for a beginner, we
should state that and (I would argue) it should probably be corrected
later in the book once the beginner is at a point where they can manage
the unsimplified version.
The practical outcome of misleading students used to come up from time
to time. For example, I would set exercises and find that students
would present solutions which only worked when compiled with a specific
compiler and/or executed on a specific platform**.
Simplification for the beginner is a good thing, but it shouldn't be
that the beginner gets a nasty surprise later on when someone says
"You're doing that wrong!". It can be very embarrassing for them.
* I taught it at Undergraduate level for a number of years, and was sent
dozens of books for review, and there were many that were just bad in
a variety of different ways.
** The worst case of this, I had to find an old version of Windows,
compile it with an obscure compiler and it still didn't work
properly. The student felt hard-done-by that he lost a lot of marks (I
wrote the markscheme so that I could still give marks for concepts - it
was an SE module which explicitly used C++ rather than a C++ module)
because the book he used (which was designed to go with this compiler)
contained examples which he based his submission on. It just didn't
match the language and didn't work as advertised.
I *had* warned them that I would be testing them with g++ on Linux
and VC++ on Windows (with specified versions), so I wasn't just being
mean.