HyperSpec says on read-preserving-whitespace:
;; read-preserving-whitespace is exactly like read when the recursive-p
;; argument to read-preserving-whitespace is true.
But later it provides an example with recursive-p set to t:
(defun slash-reader (stream char)
(declare (ignore char))
`(path . ,(loop for dir = (read-preserving-whitespace stream t nil t)
then (progn (read-char stream t nil t)
(read-preserving-whitespace stream t nil t))
collect dir
while (eql (peek-char nil stream nil nil t) #\/))))
(set-macro-character #\/ #'slash-reader)
And states:
;; Consider now calling read on this expression:
;;
;; (zyedh /usr/games/zork /usr/games/boggle)
;;
;; [...] The entire example expression should therefore be read as
;;
;;
;; (zyedh (path usr games zork) (path usr games boggle))
;;
CMUCL/SBCL produces the identical result:
* (with-input-from-string (in "(zyedh /usr/games/zork /usr/games/boggle)")
(read in))
(ZYEDH (PATH USR GAMES ZORK) (PATH USR GAMES BOGGLE))
However, in 23.1.3.2 The RECURSIVE-P argument, HyperSpec states:
;; 2. A recursive call does not alter whether the reading process
;; is to preserve whitespace[2] or not (as determined by whether
;; the outermost call was to read or read-preserving-whitespace).
According to this rule the above call to READ should produce:
(ZYEDH (PATH USR GAMES ZORK USR GAMES BOGGLE))
instead.
Which is correct?
Thanks,
Takehiko
Hmm. This indeed looks weird.
Both GCL 2.6.6 and CLISP 2.38 (on WinXP) get:
(ZYEDH (PATH USR GAMES ZORK USR GAMES BOGGLE))
However SBCL 0.9.9 (on WinXP) gets:
(ZYEDH (PATH USR GAMES ZORK) (PATH USR GAMES BOGGLE))
Looks like this is not a particularly well defined portion of CL.
Alan Manuel K. Gloria:
> Hmm. This indeed looks weird.
>
> Both GCL 2.6.6 and CLISP 2.38 (on WinXP) get:
> (ZYEDH (PATH USR GAMES ZORK USR GAMES BOGGLE))
>
> However SBCL 0.9.9 (on WinXP) gets:
> (ZYEDH (PATH USR GAMES ZORK) (PATH USR GAMES BOGGLE))
>
> Looks like this is not a particularly well defined portion of CL.
I am inclined to think that SBCL is wrong here.
If we ignore the example, the standard is consistent.
And examples are not formally a part of the standard
(1.4.3).