Path: utzoo!mnetor!uunet!husc6!mailrus!nrl-cmf!ames!umd5!uvaarpa!virginia!scl From: scl@virginia.acc.virginia.edu (Steve Losen) Newsgroups: comp.lang.pascal Subject: Scope question Message-ID: <718@virginia.acc.virginia.edu> Date: 29 Mar 88 19:40:24 GMT Organization: Academic Computing Center, University of Va. Lines: 56 The following pascal program compiles and outputs "10" with the Berkeley pascal compiler "pc". program test(output); const c = 10; procedure junk; const c = c; { Shouldn't this be an error ? } begin writeln(c) end; begin junk end. According the the ISO pascal standard: "The occurrence of an identifier in a constant-definition of a constant-definition-part of a block shall constitute its defining-point for the region that is the block. The constant in a constant-definition shall not contain an applied occurrence of the identifier in the constant-definition." constant-definition-part = [ "const" constant-definition ";" { constant-definition ";" } ] . constant-definition = identifier "=" constant . constant = [ sign ] ( unsigned-number | constant-identifier ) | character-string . constant-identifier = identifier . As far as I can tell, then, the pascal fragment const c = c; should not be allowed even if c is a constant defined in an enclosing block. Is my interpretation of the pascal standard correct? Since I'm writing a pascal compiler, I need to have this issue cleared up. A further note: The Berkeley pascal compiler also accepts fragments like this: type thing = array [1..10] of thing; { where "thing" is a type defined in an enclosing block } This also appears to be illegal according to the ISO pascal standard. Does anyone out there agree/disagree/care? -- Steve Losen scl@virginia.edu University of Virginia Academic Computing Center