Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: general data structures are impossible Message-ID: <4789@goanna.cs.rmit.oz.au> Date: 19 Feb 91 11:50:43 GMT References: <1991Feb12.013413.24312@cs.ubc.ca> <4765@goanna.cs.rmit.oz.au> <17914@cs.utexas.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 37 In article <17914@cs.utexas.edu>, turpin@cs.utexas.edu (Russell Turpin) writes: > It takes greater mathematical sophistication to understand > infinite data structures. I can explain a circular queue to > the average sophomore taking a Pascal class in about three > minutes. *PLEASE* come and teach my 2nd year Pascal data structures class for me! Look, folks, the answer is simple. There *are* data structures ("rats' nests") that are hard to do using Prolog. Never mind the fact that Prolog implementations (some via hacks, some via principled redefinition of equality) may let your program handle cyclic terms. If the Pascal operations involve *changing* pointers, cyclic terms aren't enough. They don't like being changed. There are three approaches. 1. Sit back and whine. (If the hat fits...) 2. Decide to be logical about it. If you want to represent a finite set of arcs *DO* *IT*, don't delude yourself that Prolog variables are the same thing as Pascal pointers. That means not going as fast as Pascal pointer hacking. So? What god said on which mountain that Prolog _had_ to be good at everything? 3. Remember that data structures are MEANS, not ENDS. Redesign the program so that it can use data structures that Prolog _is_ good at. (We have an absolute guarantee that the slowdown is never going to be more than O(lgN) where N is the number of items in a collection.) What, for example, is the task for which `cones' are an appropriate tool? (I've never met them before, so this is a genuine question. From the brief description we've had so far, I've no idea what they represent or what the operations on them are.) -- Professional programming is paranoid programming