"Charles Richmond" <ri******@comcast.netwrote in message
news:45***************@comcast.net...
Keith Thompson wrote:
>>
Charles Richmond <ri******@comcast.netwrites:
[...]
ISTM that the C standard could be shorted by 80% if all the special
cases were eliminated. These cases were introduced to allow some
odd-ball implementations to squeak in under the standards fence.
For instance, just say "NULL is always 0". If you can *not* implement
NULL this way, go home and think about how to fix *your*
implementation,
*not* change the standard.
I don't see how specifying the representation of a null pointer would
shorten the standard significantly.
What *would* shorten the standard would be to drastically simplify the
concept of null pointer constants. Drop the stuff about special-case
conversion of an integer constant expression with value 0. Add a new
keyword, say "nil" or "null", and make it the *only* valid null
pointer constant. Don't bother specifying how null pointers are
represented. (This is basically what Pascal and Ada do. Programmers
in those languages don't care how null pointers are represented, only
that they compare equal to null pointers and unequal to non-null
pointers.)
This wouldn't shorten the standard by a whole lot, but it would
certainly shorten section 5 of the comp.lang.c FAQ.
Of course it's not possible to do this without breaking existing code,
so it will never happen.
The NULL pointer and exceptions associated therewith...were only an
example. My point is that the C standard is replete with exceptions
to allow strange systems to be standard. ISTM that this comprises
the bulk of the current C standard. I say simplify the standard and
let the strange, non-conforming implementations change to match it.
Old code that is broken...will be broken. It can work under K&R or
something. New code shoule match the standard.
If you've got a strange system it is normally strange for a reason, not
because some evil engineer decided to mess ANSI up.
That reason is highly likely to be performance requirements. If null
pointers can't be all zero, likely either the hardware is very cheap and
needs zero as one of its 256 bytes of writeable memory, or is very expensive
and has some wonderful synchronous address validation system. Either way,
specifying extra operations to make all-zero null is effectively saying that
standard C cannot run on the machine.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.