Article View: comp.lang.modula2
Article #1032Re: Implementing Abstract Lists
From: Marc Benveniste
Date: Fri, 03 Aug 1990 07:26
Date: Fri, 03 Aug 1990 07:26
48 lines
2510 bytes
2510 bytes
From article <3275@rwthinf.UUCP>, by jubo@rwthinf.UUCP (Juergen Boerstler):
> I cannot see where this approach relies on the (relatively) strong typing
> of Modula-2, nor is it very portable (if at all). The following list of
> problems can be stated:
>
> (1) List elements have to be passed per 'ADDRESS' (-> limited type checking,
> because all pointers (and CARDINAL usually) are compatible with it).
You should notice that the vulnerable operation on a list is the creation
one where the user may cheat passing a dummy address and a dummier size.
If the user relies on the following protocol to initialise its lists,
type checking is assured from there on. Remember we don't have genericity
so it cannot be safe all the way. Please note that after creation, elements
are NOT passed per ADDRESS. They are assigned to a (typed) variable.
...
FROM SYSTEM IMPORT TSIZE, ADR;
...
VAR IO_Port, Item : AnyType;
MyList : List
...
MyList := NewList(ADR(IO_Port), TSIZE(AnyType));
...
IO_Port := Item;
Insert(MyList);
...
> (3) The interface is not comprehensive enough (-> limited usability, because
> a lot of ressources are not present, e.g. 'InsertBeforeGivenElement',
> 'IsGivenElementInList', 'LengthOfList', ....).
This is a highly subjective matter... I admit I only provide some basic
primitives. We would have to agree on what lists are. Any way, I just
wanted to show an example of an almost generic-type-safe list module.
If you have better ideas, please share them! :-)
> **************************************************************************
> * Juergen Boerstler * e-mail: jubo@rwthi3.uucp *
> * Lehrstuhl fuer Informatik III * *
> * Ahornstrasse 55 * phone: +49/ 241/ 80-7216 *
> * D-5100 Aachen * *
> * West Germany * *
> **************************************************************************
Marc Benveniste
IRISA
Campus de Beaulieu
35042 Rennes Cedex
FRANCE
Technical Details
Message-ID:
<1990Aug3.072628.29413@irisa.fr>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!inria!irisa!mbenveniReferences:
<3275@rwthinf.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!inria!irisa!mbenveni From: mbenveni@irisa.fr (Marc Benveniste) Newsgroups: comp.lang.modula2 Subject: Re: Implementing Abstract Lists Message-ID: <1990Aug3.072628.29413@irisa.fr> Date: 3 Aug 90 07:26:28 GMT References: <3275@rwthinf.UUCP> Sender: news@irisa.fr Organization: IRISA, Rennes (FR) Lines: 48