[comp.lang.misc] Pointers are abstractions

gudeman@cs.arizona.edu (David Gudeman) (10/13/90)

I'm beginning to see why people have so much trouble with pointers.
Your problem is that you haven't grasped the idea of a pointer as an
abstraction.  I note the following (incorrect) comments:

In article  <PCG.90Oct12082045@odin.cs.aber.ac.uk> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes:
]
]But pointers are a useful concretion, not an abstraction...

In article  <1576@enuxha.eas.asu.edu> nelan@enuxha.eas.asu.edu (George Nelan) writes:
]Uh, ahem.  Mathematics & Pointers.  Never shall the twain meet.  Why?
]Mathematics is about relations (implies functions).  Pointers are about
]memory...

Pointers are _not_ about memory.  Do you agree that sequences are
"mathematical"?  Then so are pointers.  Here is a partial
axiomatization:

Nat is the natural numbers
Seq is the set of sequences of X

the operation [] : Seq X Nat -> X is a partial one-to-one function
mapping S[i] into some unique x in X, for S in Seq and i in Nat.

Ptr is some set such that there exists a one-to-one function from
    Seq X Int to Ptr

let the operations

&[] : Seq X Nat -> Ptr		(written p = &S[i])
+ : Ptr X Nat -> Ptr
- : Ptr X Ptr -> Nat
* : Ptr -> X

be defined, subject to the following axioms

	p = &S[i] implies *p = S[i]
	p = &S[i] implies p + j = &S[i+j]
	(p1 = &S[i] and p2 = &S[j]) implies p2 - p1 = j - i.

I just took about 15 minutes to do this, so I don't give any
guarantees about rigour, but I'd say it is a pretty complete algebra
of pointers.  This is just as abstract as anything else in
mathematics.  It is _not_ in any sense an attempt to model computation
in any form, anymore than an axiomatization of arithmetic is an
attempt to model animal husbandry.  Yes, the original idea came from
machines.  But the idea of arithmetic probably came from counting
sheep and goats.

And no, this isn't an exact description of "real" pointers (it's an
abstraction remember?).  But then axiomatizations of arithmetic don't
really describe machine implementations of arithmetic either.
-- 
					David Gudeman
Department of Computer Science
The University of Arizona        gudeman@cs.arizona.edu
Tucson, AZ 85721                 noao!arizona!gudeman

jlg@lanl.gov (Jim Giles) (10/13/90)

From article <26362@megaron.cs.arizona.edu>, by gudeman@cs.arizona.edu (David Gudeman):
> [...  Long description about the abstract semantics of pointers ...]


Congratulations.  You've reinvented a variation of one of the standard
ways to describe pointers abstractly.  It _may_ even be right, I don't
plan to check it.

You missed the point the other person was making though.  Of course
pointers can be described mathematically - a computer is a formal
system: EVERYTHING on it can be formalized mathematically.  That's
not the issue.  The question is: do you ever have to introduce
pointers into the semantic description of anything _else_?  The
almost universal answer is NO.

J. Giles

nelan@enuxha.eas.asu.edu (George Nelan) (10/13/90)

In article <26362@megaron.cs.arizona.edu>, gudeman@cs.arizona.edu (David Gudeman) writes:
| ...
| abstraction.  I note the following (incorrect) comments:
| ... 
| In article  <1576@enuxha.eas.asu.edu> nelan@enuxha.eas.asu.edu (George Nelan) writes:
| ]Uh, ahem.  Mathematics & Pointers.  Never shall the twain meet.  Why?
| ]Mathematics is about relations (implies functions).  Pointers are about
| ]memory...
| 

Perhaps this is an incorrect comment.  However, if you would have included
my disclaimer as part of the attribution then it cannot be taken as incorrect
- or correct, for that matter - because the disclaimer stated that the comment
was a GROSS OVER-GENERALIZATION.  Ok?
-- 
George Nelan, ERC 252, Arizona State University, Tempe, Arizona, USA, 85287
INET: nelan@enuxha.eas.asu.edu
UUCP: ...{allegra,{ames,husc6,rutgers}!ncar}!noao!asuvax!nelan
QOTD: ever where ever = "what" : ever

gudeman@cs.arizona.edu (David Gudeman) (10/14/90)

In article  <65671@lanl.gov> jlg@lanl.gov (Jim Giles) writes:
]Congratulations.  You've reinvented a variation of one of the standard
]ways to describe pointers abstractly.

What has been will be again,
What has been done will be done again;
There is nothing new under the sun.
				-- the words of the Teacher

]You missed the point the other person was making though.  Of course

The person said "pointers are about memory".  That is wrong.  Pointers
are not about memory, they are about sequences (though the idea can
usefuly be extended to non-linear data as well).

]pointers can be described mathematically - a computer is a formal
]system: EVERYTHING on it can be formalized mathematically.  That's
]not the issue.

No, you missed _my_ point.  It is not that pointers can be described
mathematically, it is that pointers are abstract objects.  Many of
your objections to pointers seem to be related to your mistaken idea
that pointers are no more than a way to get at machine addresses.
If pointers were no more than that, then I might agree that they do
not belong in high-level languages.

]  The question is: do you ever have to introduce
]pointers into the semantic description of anything _else_?  The
]almost universal answer is NO.

When did that become the question?  I thought the statement (not the
question) was that "pointers are not good for anything".

(and as long as I am combining articles today)

]In fact, the language I'm
]co-designing probably _will_ eventually have pointers (at least, if
]it ever developes that far).  I have pointed this out to Dan
]numerour times in past correspondence: yet another thing he
]consistently has chosen to ignore.

Well this was a well-kept secret from me.  All I ever saw was this
Type-A-personality attitude that pointers are Evil and should never be
used by Right-Thinking Programmers.  If all this heat and noise is
based on a misunderstanding I'm a little embarrassed, but I can only
read what's written there in the article.
-- 
					David Gudeman
Department of Computer Science
The University of Arizona        gudeman@cs.arizona.edu
Tucson, AZ 85721                 noao!arizona!gudeman