Subject: [clisp-list] pprint-logical-block's argument redispatched

From: Roman Belenov <[email-masked]>
Date: Wed Sep 10 04:01:02 2003

I played a liitle with pretty printing in clisp and found that
sometimes it behaves strange (IMO incorrect, but since I'm a Lisp
newbie I can miss something).

After creating simple dispatch table:

(defvar *pdt* (copy-pprint-dispatch))

(defun own-write (sexpr &rest args)
  (apply #'write sexpr :pretty t :pprint-dispatch *pdt* args))
           
(defun 3-elem-list-p (x) (and (consp x) (= (length x) 3)))

(set-pprint-dispatch
 '(satisfies 3-elem-list-p)
 (lambda (s list)
   (pprint-logical-block (s (cdr list))
      (format s "~S,~S,~S" (pprint-pop) (car list) (pprint-pop)))) 0 *pdt*)

lists of length 3 are correctly dispatched:

[123]> (own-write '(1 2 3))
2,1,3
(1 2 3)

But then I add dispatch rule for 2 element lists:

(defun 2-elem-list-p (x) (and (consp x) (= (length x) 2)))

(set-pprint-dispatch
 '(satisfies 2-elem-list-p)
 (lambda (s list)
   (format s "~S;~S" (car list) (cadr list))) 0 *pdt*)

I see that the argument of pprint-logical-block is redispatched
through new rule:

[137]> (own-write '(1 2 3))
2;3
(1 2 3)

I'm using clisp 2.31 (2.30 exhibits the same problem) under
cygwin/Windows XP.

-- 
 							With regards, Roman.