🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #157

Re: Size of sets (was: Re: type conversion question)

#157
From: Duncan C White
Date: Mon, 03 Jul 1989 18:43
109 lines
5258 bytes
In article <1296@infbs.UUCP> neitzel@infbs.UUCP (Martin Neitzel) writes:
>
>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.

In article <6328@pdn.paradyne.com> alan@oz.paradyne.com (Alan Lovejoy) replies:
>..  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.

Well, this is certainly sloppy wording on Wirth's part, but I'm not clear
whether Alan was saying that this quote is a sloppy wording of the <<syntax>>
or the <<semantics>> of set base types in Modula-2.

It seems to me that this quote is the sole definition of the <<semantics>> of
set base types.  It is immediately followed by "where N is a small constant
determined by the implementation", which clearly suggests semantics to me.


Alan then outlines a broadly syntactical argument: (cut down to save space)
>...consider the formal definition of set types:
>
>$ SetType = SET OF SimpleType.
>$ SimpleType = qualident | enumeration | SubrangeType.
>$ SubrangeType = [ident] "[" ConstExpression ".." ConstExpression "]".
>$ ConstExpression = Expression
..
[Some examples and asides on behaviours of Wirth compilers deleted]
..
>.. The only reasonable conclusion is that SET OF CHAR 
>is legal Modula-2.

Alan's argument establishes that SET OF subrange_of_char is permitted
syntactically, but does not establish:

a).	that SET OF CHAR is permitted syntactically.

and

b).	that SET OF CHAR, or come to that even SET OF subrange_of_char,
	is permitted <<semantically>>.


Taking (a) first, the only way the syntax fragment above can possibly
generate the string "SET OF CHAR" is by the rule:

	$ SimpleType = qualident | ...

Since CHAR certainly doesn't match the rules for enumeration or SubrangeType!!

I would argue that the predeclared simple types (CHAR, BOOLEAN, INTEGER and
CARDINAL) should have been explicitly classified as "simple types", but this
involves modifying the grammar, which is really a different debate..

In the absence of an explicit syntactic classification, we must fall back on
"leave everything to semantics" mode: that is, CHAR, BOOLEAN are classified as
qualidents, as indeed is almost any random sequence of alphanumerics and dots.

So, the answer to (a) is that SET OF CHAR is syntactically valid.


Moving on now to (b):

Are SET OF CHAR and SET OF [ "A".."Z" ] semantically valid ?

Well, I think Martin's argument, plus the quote being the <<semantic>>
definition of set base types in Modula-2, is sufficiently convincing to say
that SET OF CHAR is outlawed, since CHAR is simply neither a subrange nor an
enumeration.

However, I think that Alan's argument about "integers" not being capitalized,
taken together with knowing how careless Wirth is with his various editions,
is sufficiently persuasive to leave open the possibility that Wirth really
meant "a subrange with ordinal values between 0..N-1", which would allow
SET OF subrange_of_char, and SET OF [Monday..Friday], both of which would
be otherwise disallowed.

So, we're right back where I entered this debate: Wirth does not explicitly
ban SET OF subrange_of_char, but neither does he explicitly require them.
However, I maintain that the <<emphasis>> of Modula-2 is biased heavily
towards word sized sets.


Alan concludes:
>PIM simply contains errors, omissions and contradictions.  The good doctor
>wants us to DoWhatHeMeansNotWhatHeSays.

Amen to that...

	Duncan

>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.

[ Reply to: dcw@doc.ic.ac.uk or ...!ukc!icdoc!dcw ]
----------------------------------------------------------------------------
Duncan White,           |       "In the case of Mr. Lawson, I can't say
Dept. Of Computing,     |       his years as Chancellor have given him
Imperial College,       |       an understanding of the economy, but he can
London SW7		|       probably find his way around the building"
England.		|		Ian Aitken, Question Time
Technical Details
Message-ID: <919@gould.doc.ic.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!ukc!icdoc!dcw
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> <6328@pdn.paradyne.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!ukc!icdoc!dcw
From: dcw@doc.ic.ac.uk (Duncan C White)
Newsgroups: comp.lang.modula2
Subject: Re: Size of sets (was: Re: type conversion question)
Summary: Rather LONG again I'm afraid.
Message-ID: <919@gould.doc.ic.ac.uk>
Date: 3 Jul 89 18:43:36 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> <6328@pdn.paradyne.com>
Reply-To: dcw@doc.ic.ac.uk (Duncan C White)
Organization: Dept. of Computing, Imperial College, London, UK.
Lines: 109