Sam Steingold <sds@...> wrote:
> why "too coarse a grain"? could you please be more specific?
What I mean is that in general (maybe not in this particular case
though), I don't like to rely on catching errors for testing whether I
have the right to do something or not.
The general problem is that many times, a single error is used for
different reasons (this is what I call "coarse grain", and the standard
doesn't help in this matter) but you are only interested in one of them.
When you catch such an error, you're actually catching a whole bunch of
situations, including the one you're looking for, but not only, and
there's no way to know. The consequence is that in principle, catching
too many situations may in fact hide bugs.
> 2. looking through clisp/src/stream.d it appears that this is the
> function you want:
> (defun stream-device (object)
> (and (or (sys::built-in-stream-p object)
> (eq 'socket:socket-server (type-of object)))
> (handler-case (ext:stream-handles object)
> (stream-error (e) nil))))
> the only errors signaled by stream-handles are errors on invalid
> (stream-device 1)
> ==> NIL
> (stream-device *terminal-io*)
> ==> 0 ; 1
It looks perfect, thanks!
Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com