[comp.sys.mac.programmer] Readln in THINK Pascal;

mchupa@brahms.udel.edu (Michael A Chupa) (02/13/91)

> Rich Siegel	Symantec Languages Group  Internet: siegel@endor.harvard.edu
 gave a helpful response to a problem with an unexpected end of file error.

A related topic that comes up very often in my HS programming classes is 
Think Pascal's handling of CR's in text files. For example, if eoln(f) is
true, then the effect of doing a read(f,ch) is that ch = ' ', instead of
ch = chr(13) (ascii CR). I'm curious as to why this handling of returns was
done--it is the (absolutely!) only thing I prefer Turbo 1.1 over Think on!
Mike

ags@seaman.cc.purdue.edu (Dave Seaman) (02/14/91)

In article <18704@brahms.udel.edu> mchupa@brahms.udel.edu (Michael A Chupa) writes:

>A related topic that comes up very often in my HS programming classes is 
>Think Pascal's handling of CR's in text files. For example, if eoln(f) is
>true, then the effect of doing a read(f,ch) is that ch = ' ', instead of
>ch = chr(13) (ascii CR). I'm curious as to why this handling of returns was
>done--it is the (absolutely!) only thing I prefer Turbo 1.1 over Think on!
>Mike

A CR in a Macintosh text file is the Macintosh way of representing an
end-of-line character.  The Pascal standard requires implementations to treat
end-of-line characters as indistinguishable from blanks, except by the 
required function EOLN and the required procedures RESET, WRITELN and PAGE.
Therefore, the THINK implementation is correct and Turbo is wrong.

Why was it done that way?  It's a long story.  I can remember a very early
version of Pascal on a CDC 6600 which actually treated EOL as a reserved token
and allowed you to do things like

	WRITE('THIS IS A LINE OF TEXT',EOL,'AND THIS IS ANOTHER LINE.');

(this is all uppercase because everything was in CDC display code)
but this led to all kinds of problems because, on a CDC 6600, there really was
no such thing as an end-of-line character, which led to all sorts of
implementation problems.  Therefore, in a very early revision of the language,
the EOL token was dropped and the EOLN function and WRITELN and READLN
procedures were introduced.  All of this was before the first edition of Jensen
& Wirth's _Pascal_User_Manual_and_Report_ ever hit the streets.

--
Dave Seaman
ags@seaman.cc.purdue.edu

Invader@cup.portal.com (Michael K Donegan) (02/16/91)

Why is it true that if eoln(f) is true, then f^ is ' '?
This has been true since the first implementations of Pascal.  The
only reason I know of is that the CDC6600 which hosted the early
implementations only had a 6 bit characters set.  There were 64
printable characters and no control characters.  So...in lieu of
control characters, the eoln function was created.
When Pascal was implemented on other machines, it was implemented that
way because that is what the language spec says.
	mkd