🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2211

Re: Some things that pointer-less languages can't do efficiently

#2211
From: Jeff Dalton
Date: Wed, 21 Nov 1990 20:25
45 lines
2329 bytes
In article <HEZ6WP9@xds13.ferranti.com> peter@ficc.ferranti.com (Peter da Silva) writes:
>In article <3716@skye.ed.ac.uk> jeff@aiai.UUCP (Jeff Dalton) writes:
>> Another sense, perhaps more relevant to the present discussion, is
>> that in Lisp & Scheme there's no way to get a pointer to the middle
>> of a structure.  You can't have a pointer to the cdr of a list...
>
>(setq a '(foo (bar baz)))
>(setq b (cdr a))
>(rplaca b 'bog)    
                   ~=  (setf (car b) 'bog)

If you look back at my whole message, and the others I've sent on this
topic, it should be clear what I meant.  Well, perhaps not.

What you can't do is:

  (setq a '(some list))
  (setq b (pointer-to (cdr a)))

    [Here, the value of b is not (list), but rather a pointer object
    that refers to the cdr field of the cons that was (and still is,
    so far) the value of a.  The value of the expression (reference-of
    b) is (list).]

  (setf (reference-of b) 'modified-list)

and then have a = (some modified-list).  If you think of a cons cell
as having two fields, what you can't have is a pointer to the second
field.  You can, of course, assign the contents of the second field
to a variable.  (Actually, you can do it in a sense, because you can 
implement pointer-to and reference-of using a structure that contains
set and reference thunks (for example).  What Lisp lacks is a 
primitive pointer facility that does this.)

Compare

   typedef struct cons_struct {struct cons_struct *car, *cdr} *cons;

   cons a, *b;

   a = make-list("(some list)");
   b = &a.cdr;
   *b = make-symbol("modified-list");

-- Jeff
Technical Details
Message-ID: <3808@skye.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!edcastle!aiai!jeff
References: <26739:Oct1023:44:2690@kramden.acf.nyu.edu> <65450@lanl.gov> <10397:Oct1212:55:1090@kramden.acf.nyu.edu> <3975@goanna.cs.rmit.oz.au> <3716@skye.ed.ac.uk> <HEZ6WP9@xds13.ferranti.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!edcastle!aiai!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Newsgroups: comp.lang.misc
Subject: Re: Some things that pointer-less languages can't do efficiently
Message-ID: <3808@skye.ed.ac.uk>
Date: 21 Nov 90 20:25:11 GMT
References: <26739:Oct1023:44:2690@kramden.acf.nyu.edu> <65450@lanl.gov> <10397:Oct1212:55:1090@kramden.acf.nyu.edu> <3975@goanna.cs.rmit.oz.au> <3716@skye.ed.ac.uk> <HEZ6WP9@xds13.ferranti.com>
Reply-To: jeff@aiai.UUCP (Jeff Dalton)
Organization: AIAI, University of Edinburgh, Scotland
Lines: 45