Path: utzoo!attcan!uunet!nih-csl!lhc!adm!cmcl2!yale!cs.utexas.edu!usc!samsung!dali.cs.montana.edu!ogicse!zephyr.ens.tek.com!tektronix!percy!data!kend From: kend@data.UUCP (Ken Dickey) Newsgroups: comp.lang.misc Subject: Re^4: Some things that pointer-less languages can't do efficiently Message-ID: <418@data.UUCP> Date: 22 Oct 90 20:40:37 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> <415@data.UUCP> <+CI6:YD@xds13.ferranti.com> Organization: Microcosm, Beaverton, OR Lines: 62 peter@ficc.ferranti.com (Peter da Silva) writes: >In article <415@data.UUCP> kend@data.UUCP (Ken Dickey) writes: >> There are a number of programming languages, Scheme and ML among them, >> which do not have a pointer abstraction. >The *only* abstractions in scheme are a pair of pointers or a value. Gee, I thought there was this constructor CONS which takes two values. It has 2 accessors, CAR and CDR, which return the 1st and 2nd value respectively. It can be implemented in a number of ways including: (define (CONS the-car the-cdr) (define (self message) (case message ((CAR) the-car) ((CDR) the-cdr) (else (error "CONS: unknown operation" message)) )) self ; a new cons object ) (define (CAR a-cons) (a-cons 'CAR)) (define (CDR a-cons) (a-cons 'CDR)) (define x (cons 1 2)) (car x) --> 1 (cdr x) --> 2 Will you please show me the pointer "abstraction" here? How do I dereference the pointer to get a value? >And you accidentally return (cdr list) instead of list, If I accidently do (car (+ 2 "a" (cons a b))) I am in bad shape too! But it has been a long time since I did a (car '()). I don't have to dereference store addresses to sort a list. I don't care if the implementation does "cdr-coding" (lists implemented as arrays) or not. I use the abstract accessor and let the implementation do a dereference if it needs to. > you have all the >problems as you do in C when you return a pointer to the middle of the >array. Oh, sure, the *symptoms* are different, but when you have an >object (a C pointer, or a dotted pair) that can point to any arbitrary >place in any non-atomic language object (a string, or a list) you have the >exact same problem. How, exactly, does this add something called a POINTER, which I DEREFERENCE to get a value, into the language? I can easily add a BOX abstraction which I can have multiple references to, and do the "call by reference" types of things. This is not part of the language standard. It is true that there are pointers all through typical implementatons of Scheme, but there is no "pointer" in the definition of the language! -Ken Dickey kend@data.uucp [We can get into C bashing off-line as a seperate topic if you like, it is really too embarrasingly easy to do in public]