Xref: utzoo comp.lang.modula2:2930 comp.edu:3453 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!uunet!saxony!dgil From: dgil@pa.reuter.COM (Dave Gillett) Newsgroups: comp.lang.modula2,comp.edu Subject: Re: Implementing Abstract Lists Keywords: modula Message-ID: <290@saxony.pa.reuter.COM> Date: 1 Aug 90 18:18:04 GMT Organization: Reuter:file Inc (A Reuter Company) Palo Alto, CA Lines: 27 Have you read _Abstract Data Types in Modula-2_, by R. Harrison of the Department of Electronics and Computer Science, University of Southampton, UK? I picked up this book because it discusses implementation of list, queue, graph, and various sorts of tree structures in Modula-2. I'd been hoping, particularly with the title's reference to abstract types, to find a general "list" implementation that might apply to lists of any sort, and so on. So I was severely disappointed to discover that the "List" module presented does not in fact deal with lists in the abstract, but with lists of things of type "ItemType" which is imported from some other module. So in a typical real-world program, if I have three types of things that I want lists of, I need three (almost but not quite identical) copies of the List module as presented. This is absolutely not acceptible, and I fear that it may illustrate the difference between academic theory and engineering practice. I've pretty much resolved that my own "List" module is going to need, as a parameter, the offset from the start of a record (of whatever type are in this list) to a field which contains the link field(s) and any other information that the List module needs. (One of the side effects is that I can have a single set of records participate in multiple lists, in different orders.) So I'm looking for a simple, and preferably portable, way to (a) calculate, and (b) use, the offset. Pointer arithmetic is possible, but I'm developing on the PC so that approach may not be simple or portable. Any suggestions?