Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.scheme Subject: Re: open-input-file [topics from hell, part 2] Message-ID: <5405@goanna.cs.rmit.oz.au> Date: 26 Apr 91 05:01:29 GMT References: <9104211907.AA25632@august> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 45 In article , jaffer@zurich.ai.mit.edu (Aubrey Jaffer) writes: > How about this as a solution: [(open ...) return special ports] > the value of the symbols: > file-does-not-exist > path-does-not-exist > insufficient-priveledge-to-access-file > insufficient-priveledge-to-access-path > file-system-unavailable Unacceptable. To start with, you've provided evidence that some people can't spell the names (there is no "d" in "privilege"). To continue, I can't figure out what "path-does-not-exist" means (does it mean *directory* does not exist?). And to finish, a quick "man open" on this version of UNIX revealed TWENTY-THREE error cases, not 5, and that number of error cases is just _tiny_ compared with some operating systems I've used (that had Lisp on them). Where, for example, have you provided for the case "there is no space left on that device"? Considering these points, we learn that 1) The set of error outcomes depends on the operating system 2) The set of error outcomes may be large 3) We should not have a large set of error names, a set which varies from system to system, polluting the global namespace. An alternative in keeping with the spirit of this approach would be to have a class of error objects, so that (open...) would return either something satisfying port? or something satisfying error?, and amongst the operations on error objects there might be an error-name, so that instead of > The error conditions can be checked for by (eq? file-does-not-exist port) we might have (if (error? port) (if (string-ci=? (error-name port) "ENOENT") ... This approach has the same advantage as returning #f, namely that if you don't check you will still get an error report as soon as you try to use an error object as a port. But this begins to sound like the Common Lisp condition system. -- Bad things happen periodically, and they're going to happen to somebody. Why not you? -- John Allen Paulos.