Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!cit-vax!elroy!ames!sri-spam!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.pascal Subject: Re: Pascal Enumerated I/O Message-ID: <673@cresswell.quintus.UUCP> Date: 20 Feb 88 07:17:49 GMT References: <11903@brl-adm.ARPA> Organization: Quintus Computer Systems, Mountain View, CA Lines: 51 Danny Sharpe wrote: > > I'm trying to find out if any version of Pascal running on any machine > > supports I/O on enumerated data types. Example: > > ... > > I think I've heard of versions of Pascal that allow I/O on enumerated > > types, but I can't for the life of me remember any specifics. If you mean something like type foo = (......); var baz : file of foo; I believe it is required by the standard. "pc" on a SUN supports it. If you mean type foo = (.....); var ugh : foo; begin writeln(ugh); end this is not part of the standard, but there are several compilers that support it. The B6700 Pascal compiler from Arthur Sale's group at the University of Tasmania is such a compiler. If it comes to that, so is the SUN Pascal compiler. Here is a program: program main(input, output); type foo = (here, there, back, again); var ugh : foo; begin for ugh := here to again do writeln(ugh); end {main}. Here is its output: here there back again You can also read values of enumerated types from text files. 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. > 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.