Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pucc-i Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!inuxc!pur-ee!CS-Mordred!Pucc-H:Pucc-I:ags From: ags@pucc-i (Seaman) Newsgroups: net.micro Subject: Re: Arrays in Apple PASCAL Units? - (nf) Message-ID: <240@pucc-i> Date: Mon, 26-Mar-84 12:28:51 EST Article-I.D.: pucc-i.240 Posted: Mon Mar 26 12:28:51 1984 Date-Received: Wed, 28-Mar-84 00:24:22 EST References: <1138@inmet.UUCP> Organization: Purdue University Computing Center Lines: 40 The March, 1984 BYTE has an article on "Pascal's Design Flaws: Modula-2 Solutions and Pascal Patches" by Mark C. Johnson and Allen Munro. The article lists "Pascal's Seven Deadly Sins" and demonstrates how each of these problems is solved in Modula-2, and how Pascal programmers can work around the problems. One of the seven flaws in Pascal is, of course, the lack of open array parameters. In Modula-2, one can declare PROCEDURE Foo(VAR A : ARRAY OF Bar); and have Foo compatible with all arrays of Bar, regardless of size or index type. As a special case, the declaration PROCEDURE Baz(VAR B : ARRAY OF WORD); is compatible with any Modula-2 type (the actual parameter doesn't even have to be an array type). If you don't have Modula-2 on your Apple, there are at least two ways to work around the problem. One method, described in the article and already mentioned on the net, involves a type "array[0..0] of bar", disabled range checking and some games with variant records. Another method is available in Apple Pascal if you are willing to write the library routine in assembly language. Just declare it procedure Baz(var B); external; and it will be compatible with any variable (regardless of type), just like the Modula-2 declaration above. Unlike the Modula-2 procedure, your assembly language routine won't be able to find out how large the actual parameter is unless you pass that information as another parameter. -- Dave Seaman ..!pur-ee!pucc-i:ags "Against people who give vent to their loquacity by extraneous bombastic circumlocution."