Path: utzoo!attcan!uunet!mcsun!ukc!mucs!chl From: chl@cs.man.ac.uk (Charles Lindsey) Newsgroups: comp.lang.misc Subject: Re: C's sins of commission Message-ID: Date: 9 Oct 90 08:42:11 GMT References: <151675@felix.UUCP> <64618@lanl.gov> <2883@igloo.scum.com> Organization: Dept. Of Comp Sci, Univ. of Manchester, UK. Lines: 65 In <2883@igloo.scum.com> nevin@igloo.scum.com (Nevin Liber) writes: >I really hate to agree with you Jim :-), but I'm beginning to think >that you are right. The only real argument I can see _for_ having >pointers is efficiency; .... I disagree. Other posters have suggested that recursive data structures will do all that is needed (sorry, I do not know how to make this newsreader followup to two postings simultaneously ;-) ). The situation when pointers are the only solution is when the real world situation that you are modelling is best represented by a graph. Then you encounter the situation where you may need to know whether two nodes are equivalent (in the recursive sense that their connectees are equivalent), or whether they are identically the same node. The difference is important if you need to modify one of those nodes (do you expect the other to get changed as well). Here is an example. LET twice: BE lambda(x: ) x + x; That is an expression in some language, and one would expect to represent 'x + x' by some tree. twice (1 OR 2) Here OR is a nondeterministic choice operator (some people write it as a square box, but my terminal won't oblige :-( ). It means I want twice(1) or twice(2). Now unfold the call, and we get (1 OR 2) + (1 OR 2) which one would also expect to represent by some tree. Now we have two nondeterministic choices, so let us choose 1 for the first and 2 for the second, and the result of the addition is 3. This is neither twice(1) nor twice(2). Now we really ought to have represented these expressions by graphs. | + | \ / \ / | x which unfolds to | + | \ / \ / | 1 OR 2 Now with pointers, this is easily implemented. But with recursive data types it is impossible (at least in any straightforward way - can anyone tell me how to do this in a functional language). I can do it in Smalltalk, where the pointers certainly exist, and so near to the surface that you can hardly fail to notice them. In particular, Smalltalk provides two equality operators: '=' to compare values and '==' to compare pointers.