Language transitions

Jon Mauney mauney at ncsu.UUCP
Tue Feb 19 01:08:45 AEST 1985


I say:
>> Of the many flaws in Pascal, ordinary I/O is not one.  There is nothing
>> preventing good interactive execution of Pascal programs.

<mike says
> Except (staying within the semantics of J&W, of course!):
> 
> 1) Getting read/write to work as expected on an interactive system. I've
> heard that it can be done right while still maintaining the J&W semantics,
> but have never seen it so done.
> 
> 2) Doing the *exact* equivalent of printf("Gimme data: "); with the
> cursor left at the end of the line.

The trick is to do lazy evaluation on input, and to be careful how you
buffer the output.  The definition of I/O in J&W  is very simple,
concerning itself with contents of the file pointer and the values
of the eof and eoln flags. Despite what the implementers of UCSD Pascal
seem to think,  it is not necessary to get the next input character until
the code actually tries to use it.  Berkeley's Pascal compiler does lazy
evalution of input, and it works just fine; about the same as C, in fact.
As for     write('Gimme The Ax: ');
J&W say nothing about buffering the output, so there is nothing to prevent
write statements from having an immediate effect.

I have written interactive programs in Pascal, and they conform to
a reasonable interpretation of Jensen and Wirth.
-- 

*** REPLACE THIS LINE WITH YOUR SIGNATURE ***

Jon Mauney    mcnc!ncsu!mauney    C.S. Dept, North Carolina State University



More information about the Comp.lang.c mailing list