Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site oliven.UUCP Path: utzoo!linus!philabs!pwa-b!utah-gr!utah-cs!seismo!harvard!godot!mit-eddie!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!oliveb!oliven!rap From: rap@oliven.UUCP (Robert A. Pease) Newsgroups: net.lang.mod2 Subject: Re: variable-length dynamic objects Message-ID: <799@oliven.UUCP> Date: Sat, 2-Feb-85 18:30:15 EST Article-I.D.: oliven.799 Posted: Sat Feb 2 18:30:15 1985 Date-Received: Thu, 14-Feb-85 03:40:16 EST References: <262@gumby.UUCP> Distribution: net Organization: Olivetti ATC, Cupertino, Ca Lines: 48 >> . . . . Thus I started to write: >> >> TYPE Image = RECORD >> number_cols : CARDINAL; >> number_rows : CARDINAL; >> image : ??? >> >> >> There is no way to have a streach array in MODULA 2! The only >> variable size data structure is a linked list! >> >> -David Sher > >However, I would like to draw your attention to page 161 of the second edition >of Wirth's book: > > The type ADDRESS is defined as > > ADDRESS = POINTER TO WORD > >Also note on page 158 the existence of the procedure ALLOCATE from module >Storage, which takes a var address parm and a cardinal size, and allocates >a module of the requested size. Your record, as described above, can contain >the horizontal and vertical sizes, and a variable of type ADDRESS, pointing >to a buffer allocated in this fashion, and functions may be defined to ref- >erence locations within this image array in any way you wish, with the caveat >that no array bounds checking will be possible. >-- > Dan Frank This tends to illustrate something that I have felt for a long time. People who are used to (and like!) another programming language, especially C programmers, tend to not like Modula-2 because it behaves differently from what they are used to. They cannot easily see how to perform a specific task and think that it cannot be done in Modula-2 at all. This is not to say that there is a competition only between Modula-2 programmers and C programmers. It exists between all programmers who have become very familiar with a particular language. It even exists between users of different editors. I wonder if it may have something to do with the tendency of people to resist change? By the way, Modula-2 can support dynamic allocation of string variables if the programmer doesn't insist on overloading operators. See the example above for a hint how. -- Robert A. Pease {hplabs|zehntel|fortune|ios|tolerant|allegra|tymix}!oliveb!oliven!rap