Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!think.com!mintaka!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: <3716@skye.ed.ac.uk> Date: 7 Nov 90 20:45:21 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> Reply-To: jeff@aiai.UUCP (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 27 In article <3975@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: >(Since Lisp has rplaca/rplacd -- or, in Scheme, set-car!/set-cdr! -- Lisp >is a very poor example of a "pointerless: language...) In Lisp/Scheme, everything (all values of variables) is essentially a pointer. But then you can factor out the phrase "pointer to" and regard variables as naming the objects directly. So that's a sense in which Lisp and Scheme don't have pointers. 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, to the 3rd element of an array, etc. It is possible in some Lisps, where such things are (usually) called "locatives". It is locatives that are most like pointers in other languages. Locatives can be simulated in Lisps that don't have them by using functions. For example, here is a "pointer" to the 3rd element of a vector: (defstruct loc read write) (make-loc :read (lambda () (aref v 3)) :write (lambda (x) (setf (aref v 3) x))) -- jeff