Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!uunet!mcsun!ukc!cf-cm!cybaswan!cslaurie From: cslaurie@cybaswan.UUCP (Laurie Moseley ) Newsgroups: comp.lang.pascal Subject: Re: Overflow error Message-ID: <2547@cybaswan.UUCP> Date: 15 Jun 91 20:22:13 GMT Article-I.D.: cybaswan.2547 References: <2bdd60c9e7152849799c@rose.uucp> Reply-To: cslaurie@cybaswan.UUCP (Laurie Moseley (Comp Sci)) Lines: 44 Surely any file-reading should be done in a WHILE NOT EOF loop, rather than a REPEAT UNTIL EOF one. The whole point of the WHILE is that it may be entered zero times, and therefore you are automatically guarding against the danger of trying to read from an empty file. In general the use of WHILE for the traversal of many structures (queues stacks etc) is good practice anyway, as it removes at a stroke the need for a lot of special case checking, such as testing for nil pointers. I reserve the use of REPEAT UNTIL for cases where I know that the loop will be entered at least once - keyboard input data checking for example, or a sort routine. It was invented only for convenience after all, and can be emulated by a WHILE. What's all this stuff about GETSTRING; - a parameter-less procedure. OK, there may be occasions when you need one, but they are rare in these days when one actually re-uses code. I don't believe that it is purist to shudder at such constructions, it's simply commonsense. You may get away with parameter-less procedures occasionally, but all too frequently one of two things will happen. You'll either get identifier confusion and manipulate a global unintentionally (and have some interesting evenings trying to find that !) or you will find that you have written the same procedure 7 times before you realise that it IS the same one. I guess that the point is that if you get into good habits early, you have fewer disasters later. To put on the humility hat for a moment - am I missing something important here ? Laurie ========================================================================== Laurie Moseley Computer Science, University College, Swansea SA2 8PP, UK Tel: +44 792 295399 JANET: cslaurie@uk.ac.swan.pyr ========================================================================= "Why does the Turing test set such abysmally low standards ?" ===========================================================================