Article View: comp.lang.misc
Article #1794Re^4: Some things that pointer-less languages can't do efficiently
From: Ken Dickey
Date: Mon, 22 Oct 1990 20:57
Date: Mon, 22 Oct 1990 20:57
66 lines
2873 bytes
2873 bytes
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.
No closures, strings, arrays, numbers?? Gosh Batman, they were there
the last time I looked.
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 can
dereference get a bit pattern in the store (memory)--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]
Technical Details
Message-ID:
<419@data.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!nih-csl!lhc!adm!cmcl2!yale!cs.utexas.edu!samsung!dali.cs.montana.edu!ogicse!zephyr.ens.tek.com!tektronix!percy!data!kendShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!nih-csl!lhc!adm!cmcl2!yale!cs.utexas.edu!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: <419@data.UUCP> Date: 22 Oct 90 20:57:59 GMT Organization: Microcosm, Beaverton, OR Lines: 66