Subject: Re: R5RS vs. "In Scheme, everything is a pointer"
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 10 Sep 2001 09:53:18 GMT
Newsgroups: comp.lang.scheme
Message-ID: <9ni2ie$i02j1$1@fido.engr.sgi.com>
Radey Shouman  <Shouman@ne.mediaone.net> wrote:
+---------------
| And it is, of course, exactly what many Scheme implementations
| actually do:  The value of a pointer to a pair, considered as an
| integer, is exactly the same as that of a pointer to the car of
| that pair.
+---------------

Some implementations, but certainly not all. Other popular choices
for "the value of a pointer to a pair considered as an integer":

- A pointer to an object descriptor word that precedes the car & cdr.

- A pointer to the cdr (makes list-chasing faster for some hardware
  architectures).

- The address of the car (or cdr) plus some small integer encoding
  the type. E.g., in a 32-bit Scheme, if heap objects are allocated
  on eight-byte boundaries, then you can encode coarse type information
  in the least-significant three bits of the "pointer".

- A simple integer index into a global heap object table (as in many
  Smalltalk implementations), which in turn either contains a value
  (if it's small enough) or a pointer to an object.

That's why I earlier suggested talking about object "designators"
rather than "pointers". The only key requirements on an object
designator is that a Scheme "location" (as in, one of those "fresh"
things that a variable gets bound to) can hold one of them, and
if you pass one as a parameter the called subroutine gets the "same"
object (in the sense of "eq?"). Whether an object designator is an
integer or a pointer or a small C struct (as in Elk) is thus completely
an implementation decision, and has [*must* have!] no observable effect
on the Scheme semantics.


-Rob

-----
Rob Warnock, 30-3-510		<rpw3@sgi.com>
SGI Network Engineering		<http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA

[Note: aaanalyst@sgi.com and zedwatch@sgi.com aren't for humans ]