Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!ogicse!decwrl!elroy.jpl.nasa.gov!ucla-cs!bath.cs.ucla.edu!rowley From: rowley@bath.cs.ucla.edu (Michael T Rowley) Newsgroups: comp.lang.eiffel Subject: Re: BASIC TYPES Message-ID: <32212@shemp.CS.UCLA.EDU> Date: 23 Feb 90 01:46:18 GMT References: <254@eiffel.UUCP> <1864@clyde.concordia.ca> <251@eiffel.UUCP> <1799@novavax.UUCP> Sender: news@CS.UCLA.EDU Reply-To: rowley@cs.ucla.edu Organization: UCLA Computer Science Lines: 46 In article <254@eiffel.UUCP>, bertrand@eiffel.UUCP (Bertrand Meyer) writes: > [Intervals] will not help us very much since for n of type INTERVAL we > have no static way of determining whether n + 1 is still > compatible. > > In all these cases we will have to resort to assertions anyway. > > All this is not surprising. We should not hope that a > static type system will magically solve problems that are > fundamentally dynamic in nature. > > The problem is not essentially different from the situation with > interval types in Pascal, as analyzed by A. Nico Habermann > (``Critical Comments on the Programming Language Pascal'', > Acta Informatica, 3, 1973, pages 47-57). > I have to disagree with statement that these problems are dynamic in nature. Significant research has been done with "strengthened" types to make it possible to catch range errors at compile time. The main reference I have is Paul Eggert's 1981 Ph.D. dissertation, which is available as a technical report from UCLA. Since then, he has gone to Twinsun, where they are developing "C-cured" which uses strengthened types. I am not an expert on the subject, but it involves having the compiler know about subranges, and making sure that all assignments are to conforming expressions (expressions that result in the same or smaller range as the lvalue). This changes the way some code is written, for example "n = n + 1" is never allowed. But the comparisons I have seen between code written without vs. with strenthened types convinced me that the restrictions do not add to many lines to the code. The original version was from an Introductory programming textbook, and the conversion brought to light 3 logic errors from the published original. Both the original and the converted version had 250-300 lines of code (depending on indenting style). More recent papers could probably be obtained by contacting Paul Eggert at Eggert@twinsun.com. - MTR P.S. I have nothing to do with the C-cured project. I saw a talk given by him, and think that some of the concepts could benefit eiffel.