Path: utzoo!mnetor!uunet!husc6!bbn!uwmcsd1!ig!agate!pasteur!ames!amdahl!dlb!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.pascal Subject: Re: Sun Pascal bug? Message-ID: <316@goofy.megatest.UUCP> Date: 9 Mar 88 00:37:09 GMT References: <14461@oddjob.UChicago.EDU> Organization: Megatest Corporation, San Jose, Ca Lines: 132 in article <14461@oddjob.UChicago.EDU>, vinson@oddjob.UChicago.EDU (Michael Vinson) says: > > In article <301@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: >> >>Reading strings with a readln in Pascal is not a standard feature. I am >>not in the habit of defending Pascal, especially its I/O, but I can see >>why it is not a feature: What is a string? The entire file? The next >>80 chars in the file? The characters up to the next white-space char? >>Up to the next line-end? Should the string-variable be null-terminated >>or blank-filled? > > This question is easily answered. A string is a sequence of characters > terminated by an eoln. Thus one can writeln a string (which is, I believe, > allowed in standard Pascal), and subsequently readln the same string. This > sort of symmetry is always desirable; any time you write something, there ^^^^^^^^ ^^^^^^^^^ > should be an analogous way to read it. > Sorry, but I'm going to have to mark you down a whole letter grade for this answer. You obviously have not read the assignment. You didn't even attempt to answer the part about blank-filling when the string you read is shorter than 80 chars. And I can't even give you partial credit for the part you did answer. Sorry. Consider this: You can "write" a string and no line-end will go to the output file. It's that "ln" suffix that does the trick. But if you only write it, without the "ln", then try to "read" the string, where's your symmetry? Notice that the character representation of floating point numbers is not necessarily terminated by an eoln, but you can writeln them, then readln them, as well as write then the read them. The desirable symmetry would fill your heart with boyish delight. For your info, "writeln(foo)" just means, "write(foo); writeln;". That's all. And "readln(foo)" is defined to mean "read(foo); readln". And you know what "readln" does? Way down there in the mysterious runtime support library? Here it is, dusted off and exposed to the light of day: READLN(curfile) register struct iorec* curfile; { while(!TEOLN(curfile)) GET(curfile); GET(curfile); } Yep. It just throws away the input up to and including the next new-line character. Whoopty-do. >>But then, all this is not really too important is it? >>Just write the dad-gum GetString procedure. > > Yeah yeah. The problem then is that you either have to include the file > var explicitly, as in > > procedure GetString(var FileVar : text; var TheString : string); > > in which case you have to call GetString(input,MyString) to read from > standard input (the keyboard), or else you need two separate > procedures, one for reading the keyboard, one for reading from a file. > Either "solution" is still annoying (I've chosen the former). ^^^^^^^^ > I realize this whole thing is kind of a minor point, but it is a nuisance ^^^^^^^^ > (especially after getting used to something like TP, which is far more > reasonable (but of course non standard) in its approach to I/O). > You are far too easily annoyed. Try getting more exercise. Get some walking in. Are you getting enough roughage? [His demeanor suddenly changes to one of aggression as he peers intently into the emacs buffer.] You want to know what's annoying? I'LL TELL YOU what's annoying. Annoying ISN'T when you get your first job out of school, and it's writing runtime support routines for two Pascal systems. And you argue with the standards committee about what "mod" means, and you WIN, but then you decide you argued on the wrong side. ANNOYING? Hardly! Then after a few years of Pascaling, you get a visiting professorship at a major university. Then, only then, they tell you that you HAVE to use Pascal in all of you courses, even the graduate courses. You want to hear ANNOYING? That's nothing. NOTHING!! You leave that job for a balmy position in sunny California. Doing what? Do you really have to ask? And after three and a half years basking on the beach and hacking, you have to write a new compiler for -- shall I say it? -- the "P" word. And all along... All this time... ten long years... you think Pascal is just plain silly!! Is THAT annoying? NO! THAT'S not annoying. [Pounds the table with his fist and looks up like Brother Theodore.] What's ANNOYING is that for all this time, you've been the one that people send people to with a "Pascal question". It's worse than being in the office right next to the Telex machine, and people know that you know how to use it. [He collapses on the keyboard, a totally spent ghostly shell of his former cheery good looks and suave wisdom.] kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkllllllk;k [Trying, unsucessfuly, to look composed, he raises his head and smiles weakly.] Gotta run now. There's this GetString procedure I've been meaning to write. Dave Jones Megatest Corp. 880 Fox Lane San Jose, CA. 95131 (408) 437-9700 Ext 3227 UUCP: ucbvax!sun!megatest!djones ARPA: megatest!djones@riacs.ARPA Ban the smiley.