Path: utzoo!attcan!uunet!pdn!oz!alan From: alan@oz.nm.paradyne.com (Alan Lovejoy) Newsgroups: comp.lang.modula2 Subject: Re: Size of sets (was: Re: type conversion question) Message-ID: <6328@pdn.paradyne.com> Date: 30 Jun 89 03:32:50 GMT References: <14226@watdragon.waterloo.edu< <7465@xenna.Encore.COM> <6187@pdn.paradyne.com> <985@maestro.htsa.aha.nl> <6197@pdn.paradyne.com> <912@gould.doc.ic.ac.uk> <1296@infbs.UUCP> Sender: news@pdn.paradyne.com Reply-To: alan@oz.paradyne.com (Alan Lovejoy) Organization: AT&T Paradyne, Largo, Florida Lines: 77 In article <1296@infbs.UUCP> neitzel@infbs.UUCP (Martin Neitzel) writes: >One of the original questions was "Is SET OF CHAR a legal type?". > >I just want to point out that "SET OF CHAR" must be illegal because of >the other constraints put on T. To narrow the report (already cited >by Frans van Otten) even more down: > >pim3> This must be a subrange type of the integers [...], >pim3> or a (subrange of an) enumeration type ... > >CHAR simply doesn't qualify. Your quote comes from page 150. Note that in the phrase "of the integers" the word "integers" is NOT capitalized. Hence it is not clear that Wirth means to authorize only values of type INTEGER. As evidence that Wirth did not mean that, try using one of his compilers to compile the following: ... VAR aCardinal: CARDINAL; BEGIN aCardinal := 0; IF aCardinal IN {0} THEN WriteString("Either mixed CARDINAL-INTEGER expressions are legal,"); WriteString(("or else SETs are not restricted to containing INTEGERS"); END; END ... As further proof, consider the formal definition of set types given in the next paragraph: $ SetType = SET OF SimpleType. On page 147: $ SimpleType = qualident | enumeration | SubrangeType. On page 148: $ SubrangeType = [ident] "[" ConstExpression ".." ConstExpression "]". Examples of subrange types: [0..N-1] ["A".."Z"] [Monday..Friday] The grammar in Appendix 1 says that ConstExpression = expression. Finally, try compiling TYPE CharSet = SET OF [0C..17C]; using a Wirth compiler. The only reasonable conclusion is that SET OF CHAR is legal Modula-2. >There are several places in PIM3 where subranges and enumerations are >allowed and it was necessary to add CHAR and BOOLEAN explicitly, for >example consider index types of arrays. Chapter 16 in the tutorial >section introduces BOOLEAN as a enumeration type. This is conceptually >clear and consistent within in the entire language. However, this >classification didn't make it into the reference part. Don't ask me >why. Likewise, Modula-2 could benefit from viewing CHAR as an >enumeration type in my opinion. Notice that all of Wirth's compilers blithely accept "SET OF BOOLEAN" in spite of the fact that the Report does not grant BOOLEAN the right to be called an enumeration type. PIM simply contains errors, omissions and contradictions. The good doctor wants us to DoWhatHeMeansNotWhatHeSays. Alan Lovejoy; alan@pdn; 813-530-2211; AT&T Paradyne: 8550 Ulmerton, Largo, FL. Disclaimer: I do not speak for AT&T Paradyne. They do not speak for me. ______________________________Down with Li Peng!________________________________ Motto: If nanomachines will be able to reconstruct you, YOU AREN'T DEAD YET.