Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!edcastle!cs.ed.ac.uk!jha From: jha@cs.ed.ac.uk (Jamie Andrews) Newsgroups: comp.lang.prolog Subject: Re: general data structures are [not] impossible Message-ID: <6406@skye.cs.ed.ac.uk> Date: 17 Feb 91 16:47:57 GMT Sender: nnews@cs.ed.ac.uk Reply-To: jha@lfcs.ed.ac.uk (Jamie Andrews) Organization: Laboratory for the Foundations of Computer Science, Edinburgh U Lines: 56 >From: turpin@cs.utexas.edu (Russell Turpin) >Summary: What is the point of such obfuscation? >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. To explain its equivalence as an infinite data >structures, I have to either talk about the view of the finite >structure as its pointers are infinitely chased, or I have to >talk about taking quotients, ie, mapping the infinite structure >onto the finite structure. What is the point? What is the >advantage of considering something that is essentially finite >as an infinite expansion? Oh, yeah. So you can program it >in Prolog. [Sorry for the long quote -- I thought it was necessary to get the impact of Russell's criticism.] I think there are several reasons for your feeling, which might not be the whole story, but which in any case you haven't mentioned. o In Pascal, looping data structures are seldom printed out as single entities because that's not usually the point of using them. Prolog is an interactive language in which some attempt at this must be made. If you try to print out such data structures in Pascal, the results are just as confusing. o Manipulations of such data structures are greatly facilitated by languages with explicit types, named record fields, and so on. Pascal has these; most Prologs don't. o You're taking an "operational" view of these structures, which may well be appropriate for some tasks, or for showing how the structures are implemented on the machine and why we want to use them. For other tasks, it may be appropriate to view the "pointed-to" nodes as part of the same structure as the records. In a nice LP language with a reasonable syntax, it should be possible to write very clear code which handles recursive data structures in a logical way, whether they're looping or not. In fact, the code might be nicer than Pascal because the dereferencing operation is not needed. It may still be advantageous to know about the pointer view to see how programs work; but, as in many things, the logical view may be better for certain problems. And here's an idea for the printout problem: perhaps in the declaration of data structures, the user could specify which nodes are to be printed along with the top-level structures, and which are to be printed as pointers, to be displayed further at the user's discretion. --Jamie. jha@cs.ed.ac.uk "Where in New York will I bury my twenties?"