Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!warwick!nott-cs!piaggio!anw From: anw@maths.nott.ac.uk (Dr A. N. Walker) Newsgroups: comp.object Subject: Re: A Hard Problem for Static Type Systems Message-ID: <1991May1.143831.2065@maths.nott.ac.uk> Date: 1 May 91 14:38:31 GMT References: <554@eiffel.UUCP> <1991Apr26.203642.17387@leland.Stanford.EDU> <556@eiffel.UUCP> <52166@nigel.ee.udel.edu> Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker) Organization: Maths Dept., Nott'm Univ., UK. Lines: 47 In article <52166@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes: >Besides, I still haven't seen a good example of how to do hetrogeneous >lists in a statically-typed language. Perhaps I might have a go if I understood the question better. (a) There is no difficulty [in the right language!] in writing a generic list constructor, so that given a type T you could instantiate lists of T. This could be a library routine, that needn't know in advance what T might be. This would give a homogeneous list, but different calls of the same routine would deliver lists of different types. (b) Given a set of types, say "student", "room", "teacher", "course", there is no difficulty [in languages that don't necessarily have generics but do have unions and pointers] in writing routines for lists of "union (student, room, teacher, course)". This would give a homogeneous list, but the base contents could be as heterogeneous as you [statically] liked. (c) Given a collection of ways of constructing types, say "array of", "pointer to", "procedure with parameters ... returning ...", etc., there is no difficulty [in suitable languages!] in constructing an ADT (perhaps some tree structure) which represents arbitrary types and building lists of this ADT (and/or of instantiated objects of such types). Compilers do this all the time. (d) Given a generic pointer, in languages that assume rightly or wrongly that all pointers are the same "shape", there is no difficulty in building a list of pointers to arbitrary objects. Storage allocators do this all the time. Are you thinking of something else? Or is one of (a-d) what you are after? [I have no axe to grind on the general static/dynamic debate. Dynamic typing is often more convenient, but it is, I still maintain, *necessary* only when you, the programmer, don't know what types of objects your program is going to have to deal with or what operations are going to be effected on them. That situation might be acceptable for a quick prototype, but not for a finished system. That is why it is easy to describe *situations* in which dynamic typing is desirable, but we have not seen a completely specified *problem* for which it is needed.] -- Andy Walker, Maths Dept., Nott'm Univ., UK. anw@maths.nott.ac.uk