Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!gitpyr!gus From: gus@pyr.gatech.EDU (gus Baird) Newsgroups: comp.lang.pascal Subject: Standard Pascal Message-ID: <8736@pyr.gatech.EDU> Date: 12 Jul 89 00:42:07 GMT Distribution: usa Organization: Georgia Institute of Technology Lines: 64 >Article 2169 of comp.lang.pascal: >>From: milne@ics.uci.edu (Alastair Milne) >Newsgroups: comp.lang.pascal >Subject: Re: Standard Pascal > >schwartz@shire.cs.psu.edu (Scott Schwartz) writes: >>Actually GET and PUT are much better than READ and WRITE. One reason is >>that you can interrogate the file variable without committing to read it. >>For example, to strip leading whitespace from the input stream, you >>do the following: > >> while (input^ in [space, tab, newline, cr, formfeed]) do >> get (input) > > How does this constitute not commiting to read the file variable? You are > doing exactly that when you dereference the file variable to get its > window. I don't see how this differs at all from > > repeat > read( input, ch); > until not (ch in [space, tab, newline, cr, formfeed]); > > except that you first copy what would have been the file variable > reference into another variable. Saving one variable seems to me a > trivial difference in transport. Replacing the references so that all > "input^"'s become "ch"'s is worse, but not much. > >>This works without side effects, so that it can be bundled up in a >>black box and called by anyone. No! There's a TREMENDOUS difference between repeat read(FileVar,ch) until ch {is whatever}; and while FileVar^ {is not whatever} do get(input); far beyond the trivial savings of a local variable. The point is that that the version with read consumes the character that stops the loop. This means that the routine after the skiptill routine will have to be written to get its first character from the skiptill code, and get its others from FileVar. This constitutes an unconscionable tight coupling between the routines, needlessly complicating the program and adversely affecting reliability and re-usability. We want our procedures to be as loosely coupled as possible. Turbo "Pascal" is a good language and development system, but it ain't Pascal. That's why I won't use it in my courses, where I'm training up computer scientists. Pascal's frequently-damned I/O model is actually one of its very best features - budding computer scientists who understand that model are well equipped to deal with real-world I/O systems. -- gus Baird School of ICS, Georgia Institute of Technology, Atlanta, Georgia, 30332 ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!gitpyr!gus