Pascal question

Chris Shaw cdshaw at watmum.UUCP
Fri Apr 19 16:27:59 AEST 1985


>>
>>function p(var i:integer):integer;
>>
>>begin
>>    p := i;
>>    i := i+1;
>>end (* p *);
>
>I don't have the original article handy, but it almost looks like someone
>was trying to perform the illegal:
>
>	function p(var i:integer):integer;
>
>which would be an attempt at declaring a function which returns two values.
>I pray that somewhere there isn't a compiler which would accept that. 
>-- 
>Name:		John Ruschmeyer

You should hope no such thing !!!!

If you find a Pascal compiler which won't accept this program fragment, 
THROW IT OUT, IT'S WRONG !

Many's the time I've written Pascal functions in the vein above. Quite simply,
it is a very easy way to make functions which have error checking as in C.

Thus:

	function x( var i : integer ) : boolean ;

	begin
	  blah blah blah ;
	  x := error status (success/fail);
	end;


	begin { main program }
	  if( x( y ) )then
	    play with y
	end.

Is a much more natural and useful way of saying the same thing with procedures
using multiple arguments.

(And, yes I tested this, so I'm not just blabbering )

The upshot.. If you're going to talk about a language, learn it first !

Chris Shaw
University of Waterloo



More information about the Comp.lang.c mailing list