Subject: file-position function

From: Chun-Yu Lee <[email-masked]>
Date: Wed, 8 Jun 94 20:07:25 MDT

Dear clispers,

  When I use the file-position function, there seems to be something 
different from the description in CLtR. In CLtR, the usage for 
file-position is:

   file-position file-stream [position]

and if the "position" argument is specified, the position is set to its
value and "t" is returned. A value of nil is returned if the file position
cannot be set to the value specified by "position".

However, the following results show the difference, where the file "foo"
contains only ten characters, i.e. "1234567890":

> (setq in (open "foo"))
#<STRING-CHAR-FILE-STREAM #"FOO">
> (read in)
1234567890
> (file-position in)
10
> (read in)
*** - READ: input stream ... has reached its end

> (file-position in 0)
T
> (file-position in 10)
T
> (file-position in 11)
*** - connot position #<STRING-CHAR-FILE-STREAM #"FOO"> beyond EOF
1. Break>

Is there something wrong with the usage? I'd like that it returns the nil
when the file position cannot be set.

Sincerely yours,
Chun-Yu Lee.
E-mail: [email-masked]

---

From: haible (Bruno Haible)
Date: Thu, 9 Jun 94 16:07:44 +0200

Chun-Yu Lee says:

> > (file-position in 11)
> *** - cannot position #<STRING-CHAR-FILE-STREAM #"FOO"> beyond EOF

> when the file position cannot be set.

CLtL2 (p. 656) and dpANS (23.3.0.18) specify that
  "If the integer is too large or otherwise inappropriate,
   an error is signaled."

A value of NIL would be returned if the new position were valid but could
not become the file's position for some other reason.

                    Bruno Haible
                    [email-masked]