sbigham@dukeac.UUCP (Scott Bigham) (11/22/88)
["Line-Eater vs. the Worm" now showing at a theater near you...] Thanks to everyone that had lots to say about current and upcoming Pascal standards. Just a few more questions: - Will the new standard support compile-time initialization of variables, a la the following: var j:integer:=5; z:array[1..5] of integer:=(1,2,3,4,9999999); test:record name:string; {or however X3J9 does it) ssnum:integer; end:=('John Doe',123456789); - In the new standard, can type/var/const declarations appear more than once, as in: type qq=1..5; var z:array[qq] of integer; type zmy:set of char; var m:zmy; I know I had more questions to ask; doubtless I'll think of them the minute I post this. In the meantime, advTHANKSance as always... sbigham -- Scott Bigham "The opinions expressed above are Internet sbigham@dukeac.ac.duke.edu (c) 1988 Hacker Ltd. and cannot be USENET sbigham@dukeac.UUCP copied or distributed without a ...!mcnc!ecsgate!dukeac!sbigham Darn Good Reason."
bobd@ihf1.UUCP (Bob Dietrich) (11/23/88)
In article <1119@dukeac.UUCP> sbigham@dukeac.UUCP (Scott Bigham) writes: >["Line-Eater vs. the Worm" now showing at a theater near you...] > >Thanks to everyone that had lots to say about current and upcoming Pascal >standards. Just a few more questions: > >- Will the new standard support compile-time initialization of variables, >a la the following: > >var > j:integer:=5; > z:array[1..5] of integer:=(1,2,3,4,9999999); > test:record > name:string; {or however X3J9 does it) > ssnum:integer; > end:=('John Doe',123456789); In Extended Pascal: var j:integer value 5; z:array[1..5] of integer value [1:1; 2:2; 3:3; 4:4; 5:9999999]; test:record name:string(40); {or some other size } ssnum:integer; end value [name='John Doe'; ssnum=123456789]; Some points about the example: - An initial value (actually, initial state) can be associated with a type. When an initial value is associated with a variable, it overrides the initial state of the type of the variable. The default initial state of all types is undefined. - Values are explicitly associated with a particular array index or field name, as the example shows. However, for arrays an otherwise clause allows all components that have not been explicitly initialized to be given a value. A similar mechanism is provided for variant records. Although explicitly naming the component to recieve the initial value can be more tedious than positional notation, it can allow better error checking and can make it simpler to sparsely initialize an array. - You can use structured values in constant definitions or in expressions, leading to the example assignment statement: type arrtype = array[ 1..30] of integer; var xx: arrtype; ... xx := arrtype[ otherwise 13]; which assigns each element of the array the value 13. The upper or lower bound of arrtype can be changed without changing the assignment statement. Note that in this example, the type name must precede the value constructor, whereas in the variable declaration example, the type was anonymous and determined implicitly. > >- In the new standard, can type/var/const declarations appear more than once, > as in: > >type qq=1..5; > >var z:array[qq] of integer; > >type zmy:set of char; > >var m:zmy; Yup. Label, procedure and function declarations can also come in any order. Of course, the definition before use rules must be followed as before. The only other restriction is that an import clause (to import interfaces into a block) must be before any other declarations. > > >I know I had more questions to ask; doubtless I'll think of them the minute I >post this. In the meantime, advTHANKSance as always... > > sbigham > >-- >Scott Bigham "The opinions expressed above are >Internet sbigham@dukeac.ac.duke.edu (c) 1988 Hacker Ltd. and cannot be >USENET sbigham@dukeac.UUCP copied or distributed without a >...!mcnc!ecsgate!dukeac!sbigham Darn Good Reason." usenet: uunet!littlei!ihf1!bobd Bob Dietrich or tektronix!ogccse!omepd!ihf1!bobd Intel Corp., Hillsboro, Oregon or tektronix!psu-cs!omepd!ihf1!bobd (503) 696-2092