Article View: comp.lang.misc
Article #1174Re: Pointers as 3-tuples (Re: JLG's flogging of horses (was Re: Relationship between C and C++))
From: David Gudeman
Date: Wed, 11 Apr 1990 00:24
Date: Wed, 11 Apr 1990 00:24
44 lines
2509 bytes
2509 bytes
[about the 3-tuple method for bounds checking...]
>...You have _NOT_ demonstrated that pointers _should_ obey bounds...
>
>In fact, what you are recommending is a constraint on pointers which
>removes one of the _only_ features that I thought pointers were useful
>for. I already had a pretty low opinion about the value of pointers
>and you are busy destroying what respect I had left. If it is your
>intent to make pointers seem _less_ useful than they might be, you
>are succeeding.
OK, I'm confused. I thought one of your objections to pointers was
that they can point to undefined values, and that there was no way to
do run-time error checking for this as is done for array indexes. I
showed a way to do it, and now you say that I've removed the only
advantage they have. How can you criticize pointers for having a
feature and also say that that feature is their only advantage?
The only thing I've done is provide a way to ensure that the undefined
operations are detected, causing a meaningful error message rather
than the endearing "bus error: core dumped" or just peculiar
(undefined) behavior. My proposal puts no restrictions on the
well-defined pointer operations at all.
As to whether pointers _should_ obey bounds, it would be hard to
justify any other interpretation. Notice that I am _not_ restricting
what objects pointers can point to, only ensuring that they point to
real objects. Any other interpretation would be either non-portable
or force compilers on some machines to produce extremely poor code.
Are you suggesting that it would be an _advantage_ if pointers could
be used like this?
int foo()
{ int *p, i,j,k,l,m,n;
for (p = &i; p <= &n; p++) do_something(p);
}
This sort of thing can be useful I suppose, but it is not defined in
the C language, and all I'm doing is checking that it doesn't happen.
--
David Gudeman
Department of Computer Science
The University of Arizona gudeman@cs.arizona.edu
Tucson, AZ 85721 noao!arizona!gudeman
Technical Details
Message-ID:
<20079@megaron.cs.arizona.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!ig!arizona!gudemanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!ig!arizona!gudeman From: gudeman@cs.arizona.edu (David Gudeman) Newsgroups: comp.lang.misc Subject: Re: Pointers as 3-tuples (Re: JLG's flogging of horses (was Re: Relationship between C and C++)) Message-ID: <20079@megaron.cs.arizona.edu> Date: 11 Apr 90 00:24:20 GMT Organization: U of Arizona CS Dept, Tucson Lines: 44