Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site Shasta.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!Glacier!Shasta!trickey
From: trickey@Shasta.ARPA
Newsgroups: net.lang.pascal
Subject: Re: Request for Berkeley Pascal information
Message-ID: <6830@Shasta.ARPA>
Date: Fri, 12-Jul-85 14:07:01 EDT
Article-I.D.: Shasta.6830
Posted: Fri Jul 12 14:07:01 1985
Date-Received: Sat, 13-Jul-85 15:29:45 EDT
References: <645@umd5.UUCP>
Organization: Stanford University
Lines: 48

> I am trying to convert an existing Pascal program to run under Ultrix, 
> on a VAX, but do not have access to the internal documents for this
> implementation.  The program makes extensive use of an "otherwise" clause
> in its "case" statements.  I have blindly tried all variations I have seen
> in other Pascal implementations, without success.  
> 
> Can anybody out there tell me whether there is, in fact, an extension for
> a "none of the above" case, or that such an extension does not exist?
> 
> -- 
> Ben Cranston  ...{seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben  zben@umd2.ARPA

Berkeley added a -O option to pxp sometime during 4.2.  If you do
	pxp -O prog.p > newprog.p
then prog.p can have a case labelled "others:", and pxp -O will create
a newprog.c where such case statements are changed to:
	if  in [] then
		case  of
			
		end
	else
		

If the range of the  isn't too big, the code generated is
a bit-vector membership test, which isn't too bad.  However, I
recently reduced the running time of a program by a factor of 8 by
noticing that large set membership tests get translated into a
push of all the members onto the stack, followed by a call to
a procedure to check each.  (The fix was to change that code manaully,
with a more efficient range test for the "others:" cases.)
So be warned.

When I and others ported TeX to UNIX, the "others:" problem had to be
solved.  We looked at pc's source, and found it was quite easy to add
an "others:" clause capability.  The compiler already generates code
to check for "none of the cases", since it has to produce a runtime
error for that.  We asked Berkeley if they would consider putting
the fix into pc, and they said no, because they didn't want to add
such a non-standard feature to the language (and also because more
programs than just pc would have to change to support a new language
feature).  Instead, they came up with the pxp -O solution, which
is the one used in TeX right now.  I don't think the large range
problem shows up there.

Sorry, but I don't have the changes to pc to add "others:" anymore.

			Howard Trickey
			...decwrl!Glacier!Shasta!trickey