Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!percival!parsely!agora!ihf1!bobd From: bobd@ihf1.UUCP (Bob Dietrich) Newsgroups: comp.lang.pascal Subject: Re: An ISO Pascal question... Message-ID: <577@ihf1.UUCP> Date: 20 Mar 89 20:50:37 GMT References: <18654@adm.BRL.MIL> <2824@kalliope.rice.edu> <1195@ruuinf.UUCP> <2546@elxsi.UUCP> Reply-To: bobd@ihf1.UUCP (Bob Dietrich) Organization: Intel Corp., Hillsboro, Oregon Lines: 36 In article <2546@elxsi.UUCP> uunet!elxsi!corbett (Bob Corbett) writes: >No, it is not legal. Pascal is not C. The text that follows is from >ANSI/IEEE 770 X3.97-1983 (left my copy of ISO 7185 at home). On this >point, and most others, the two standards agree. > > Bob Corbett I believe Mr. Corbett is correct in his statements that the example is incorrect Pascal. Another way of thinking about the problem is that an identifier can be used in only one way within a region; that is, it cannot be used as a type and a field identifier within the same scope (see 6.2.2.8). The example declarations define a field T within the scope of the record declaration (the region between "record" and "end"). This establishes the use of T within that scope as a field identifier. Then another field is declared using T as if it was a type identifier. This conflicts with the rule that an identifier can only be used in one way within a scope, and thus is a violation. To clarify a bit, the term "region" refers to what can be thought of a piece of program text. A block (declarations plus the compound statement), an identifier, or a record declaration are all examples of regions. The notion of "scope" in Pascal uses regions. Scope defines what an identifier means within a particular set of regions. These regions may be nested, as with nested procedure declarations, or they may be disjoint. The latter case occurs when you forward declare a procedure. The parameters are defined for a scope consisting of a region that is the procedure heading and a region that is the block of the procedure. This actually occurs for normal procedure declarations, but is easier to think of when forward is used. There are other cases as well as this one, but I think you get the point. usenet: uunet!littlei!intelhf!ihf1!bobd Bob Dietrich or tektronix!ogccse!omepd!ihf1!bobd Intel Corp., Hillsboro, Oregon or tektronix!psu-cs!omepd!ihf1!bobd (503) 696-2092