Path: utzoo!attcan!uunet!mcsun!i2unix!inria!irisa!mbenveni From: mbenveni@irisa.fr (Marc Benveniste) Newsgroups: comp.lang.modula2 Subject: Re: Implementing Abstract Lists Message-ID: <1990Aug15.115520.17350@irisa.fr> Date: 15 Aug 90 11:55:20 GMT Sender: news@irisa.fr Organization: IRISA, Rennes (Fr) Lines: 53 From vn Fri Aug 3 09:26:38 1990 Subject: Re: Implementing Abstract Lists Newsgroups: comp.lang.modula2 References: <3275@rwthinf.UUCP> 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)); (* This cannot be enforced *) ... IO_Port := Item; (* Type checking is performed here *) 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