Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.scheme Subject: Re: looking for balancing (binary/avl) tree programs Message-ID: <5898@goanna.cs.rmit.oz.au> Date: 22 May 91 08:05:14 GMT Article-I.D.: goanna.5898 References: <5863@goanna.cs.rmit.oz.au> <9105210031.aa21207@mc.lcs.mit.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 51 I wrote > The thing that really worries me is that the last line of the file that > I picked up was incomplete. It read > " (case-3)))))" > (minus the quotes), and the file just *stopped* at that point without > even the LF that one expects to terminate every line. Is anything more > than the LF missing? In article <9105210031.aa21207@mc.lcs.mit.edu>, cph@altdorf.ai.mit.EDU (Chris Hanson) writes: > There's nothing else missing. I never add a final newline to a Scheme > source file, because Scheme doesn't require it. I refuse to give in > to the short-sighted unix designers who have decided that every file > should end in a newline. These days, due largely to the influence of UNIX, we expect a file to be a sequence of ``bytes''. That works fine under UNIX, although as I mentioned a lot of tools don't quite believe it, and it works fine on Macintoshes. It doesn't quite work under MS-DOS, where traces of CP/M influence still linger. It doesn't work under VMS. VMS's "native" file formats are all record oriented. VMS does have "stream" record formats (STREAM, STREAM_LF, STREAM_CR) which basically mimic the UNIX kind of model, but RMS still requires each "record" thus delimited to be at most 32k bytes long. MVS/TSO and VM/CMS are very much record oriented; their record formats (like VMS's "native" formats) do not admit an unterminated record as a logical possibility. It's not a matter of giving in to "unix designers", it's a matter of not giving a tinker's for portability or for people who might want to read your files into other file systems, let alone try to use what you write. I wouldn't be too sanguine about Scheme not requiring terminated lines, either. Common Lisp has an operation called "read-line", and from p572 of CLtL2, "read-line reads in a line of text TERMINATED BY A NEWLINE". What relevance has this to Scheme? Well, several Schemes provide read-line (though some call it read-string). Scheme not having multiple results, the Scheme versions of read-line that I've seen are even pickier about proper termination than CL. And at a minimum, leaving the last line of a file unterminated is a discourtesy to human readers. The result looks exactly like a file which has been truncated at an inappropriate point by a mailer or a broken 'tar' or a file system which filled up while the file was being written (given the state of my 'quota', a very likely event), and so on. Some considerate programmers go so far as to include a little comment like ";; eof" at the end of their files. Don't think I haven't had occasion to be grateful for that. Another couple of times and I'll start doing it myself. -- There is no such thing as a balanced ecology; ecosystems are chaotic.