[net.bugs] Franz Lisp

yuhan@ellie.UUCP (Albert Hanyong Yuhan) (12/17/85)

     We know that the function "pp" calls "pp-form" which calls again
various functions to pretty print value, propery, and/or function
definition of a symbol.  Pp or pp-form function is very important as
it is essential to converting lisp source code files into, and 
maintaining them in, human-readable forms.
     On Franz lisp, at least, running on VAX750 in Unix 4.2, currently,
"pp-form" does not work correctly if the object to be pretty printed
is a function definition whose function name contains a non-vcharacter
in it.  The bug is where the pretty printer prints the name of such a
function.  Weirdly, printing of the body of function is done correctly
if it has some special characters to be escaped.
     This bug is not trivial if a function is recursively defined, 
and its name contains a non-special character in its name, since
the head name of the function and the recursively invoked function
names of itself are now different because of this bug.


     I looked into /usr/src/lisp/pp.l , and have discovered why it
work not correctly.  The function "printdef" calls "princ" (which,
same as patom, strips off escape symbols for special characters)
rather than calling "print".  With this fix, my test showed that
it works O.K. concerning this matter.  I suppose that the system
has to be re-made.

     I am attaching a script with some comments added so that
the problem is well illustrated in a real lisp context.


==========================================================
Script started on Tue Dec 17 11:16:40 1985
{} lisp
  ** infns/load'ing of myfns/myload suppressed **
-> (load 'show.l)
[load show.l]
t
*****************************************************************
*
HERE YOU HAVE THE CONTENTS OF THE FILE
(def ident\'fun ; the function name contains an escaped quote
  (lambda (lst)
    (cond ((atom lst) lst)
          (t (cons (ident\'fun (car lst))
                   (ident\'fun (cdr lst))]
*
*****************************************************************

-> (print (getd 'ident\'fun))
(lambda (lst) (cond ((atom lst) lst) (t (cons (|ident'fun| (car lst)) (|ident'fun| (cdr lst))))))nil


-> (pp ident\'fun)
(def ident'fun
  (lambda (lst)
    (cond ((atom lst) lst)
          (t (cons (|ident'fun| (car lst)) (|ident'fun| (cdr lst)))))))

t
-> (pp-form (list 'def 'ident\'fun (getd 'ident\'fun)))
(def ident'fun
  (lambda (lst)
    (cond ((atom lst) lst)
          (t (cons (|ident'fun| (car lst)) (|ident'fun| (cdr lst)))))))nil
-> (pp-form (list 'DEF 'ident\'fun (getd 'ident\'fun)))
(DEF |ident'fun|
     (lambda (lst)
             (cond ((atom lst) lst)
                   (t (cons (|ident'fun| (car lst)) (|ident'fun| (cdr lst))))))
     )nil
*****************************************************************
*
THE ERROR IS THAT pp-form PRINTS FUNCTION NAMES WITH ESCAPE SYMBOLS
STRIPPED OFF WHEN THEY CONTAIN SOME SPECIAL CHARACTERS IN THEM.
*
*****************************************************************



*****************************************************************
*
NOW, SEE IT WORKS CORRECTLY AFTER MY FIX.
*
*****************************************************************
-> (load 'printdef.l)
[load printdef.l]
t
*****************************************************************
*
HERE YOU HAVE THE CONTENTS OF THE FILE
(def printdef
  (lambda (l lmar rmar)
    (cond ((and (zerop lmar)		; only if we're really printing a defn
                (zerop rmar)
                (cadr l)
                (atom (cadr l))
                (dtpr (caddr l))
                (null (cdddr l))
                (memq (caaddr l) '(lambda nlambda macro lexpr))
                (null (cdr (last (caddr l)))))
           (princ '|(| $outport$)
           (princ 'def $outport$)
           (princ '| | $outport$)
           (print (cadr l) $outport$)
           ******
MY FIX FROM princ INTO print TAKES CARE OF THE PROBLEM.
           (terpri $outport$)
           (princ '|  (| $outport$)
           (princ (caaddr l) $outport$)
           (princ '| | $outport$)
           (princ (cadaddr l) $outport$)
           (terpri $outport$)
           (mapc  '(lambda (x) ($prdf x 4 0)) (cddaddr l))
           (princ '|))| $outport$)
           t))))
*
*****************************************************************
-> (pp ident\'fun)
(def |ident'fun|
  (lambda (lst)
    (cond ((atom lst) lst)
          (t (cons (|ident'fun| (car lst)) (|ident'fun| (cdr lst)))))))

t
-> (pp-form (list 'def 'ident\'fun (getd 'ident\'fun)))
(def |ident'fun|
  (lambda (lst)
    (cond ((atom lst) lst)
          (t (cons (|ident'fun| (car lst)) (|ident'fun| (cdr lst)))))))nil
*****************************************************************
*
YOU SAW THAT IT WORKED CORRECTLY WITH THE FIX.
*
*****************************************************************
-> (exit)
No files updated. 
{} 

Script done on Tue Dec 17 11:22:39 1985

-- 
--------------
UUCP   : {cmc12,hao,harpo}!seismo!rochester!rocksvax!sunybcs!yuhan
         ...{allegra,decvax,watmath}!sunybcs!yuhan
CSNET  :  yuhan@buffalo
ARPA   :  yuhan%buffalo@csnet-relay
BITNET :  yuhan@sunybcs
--------------