Path: utzoo!utgpu!water!watmath!clyde!rutgers!uwvax!oddjob!hao!gatech!psuvax1!burdvax!sdcrdcf!csun!csuna!abcscnuk From: abcscnuk@csuna.UUCP (Naoto Kimura) Newsgroups: comp.lang.pascal Subject: Re: Pascal Enumerated I/O Message-ID: <1077@csuna.UUCP> Date: 21 Feb 88 21:37:52 GMT References: <11903@brl-adm.ARPA> <673@cresswell.quintus.UUCP> Reply-To: abcscnuk@csuna.UUCP (Naoto Kimura) Organization: California State University, Northridge Lines: 48 In article <673@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >.. >In article <11903@brl-adm.ARPA>, jipping@frodo.cs.hope.EDU (Mike Jipping) writes: >> It seems to me that doing I/O on enumerated types goes against the grain >> of the concept. If you take a strict view of data typing, what does a >> compiler expect from input or print to output? Certainly not a sequence of >> characters -- for that would be a string (i.e., array of char), NOT an >> enumerated type. And certainly not a number (perhaps indicating the ordinal >> value...) for the same typing reasons. > >But a text file is precisely a sequence of characters (with some additional >structure). And Pascal *does* provide text I/O on *one* enumerated type. >It's absurd that text I/O IS allowed for Boolean, but not for other enums. Pascal allows only output, not input of booleans. What would you suggest for input of boolean variables ? Are you going to have the compiler generated code to require 'TRUE' for TRUE on text input, or are you going to allow abbreviations of 'TRUE' like 'TR' ? Booleans can be written out as text, and truncated by using a field width, so why should you not be allowed using 'T' for 'TRUE' and 'F' for 'FALSE' ? Is the input going to be case-sensitive ? Some compilers are case-sensitive, while others are not. Is case-sensitivity going to be based on whether or not the compiler is case-sensitive ? That would mean that the behavior of a program will depend upon the compiler. Strings can be truncated on output to a text file too, but they have to be read in one character at a time from a text file. > >> At best, not a portable solution... >If text I/O of enumerated types had been part of the standard, >it *would* have been portable. And it's such a simple feature to >implement, too. What a pity. Ok, then go and implement a compiler that will allow input of enumerated types. Output I can see how it could be done, but input is another story. The compiler would have to have something like yacc or lex built into it. As someone has already stated, I/O of enumerated types is contradictory to the policy of strong typing. Output of boolean values was probably allowed because they are used quite often. And anyway, I wouldn't go classifying booleans as an enumerated type, as they behave differently. //-n-\\ Naoto Kimura _____---=======---_____ (csun!csuna!abcscnuk) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!