Article View: net.bugs
Article #10Franz Lisp (at least, Opus 38.79) bug with pretty-printing
From: Albert Hanyong Yuhan
Date: Tue, 17 Dec 1985 17:54
Date: Tue, 17 Dec 1985 17:54
147 lines
5811 bytes
5811 bytes
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
--------------
Technical Details
Message-ID:
<731@ellie.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!sunybcs!ellie!yuhanShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site ellie.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!sunybcs!ellie!yuhan From: yuhan@ellie.UUCP (Albert Hanyong Yuhan) Newsgroups: net.bugs,net.lang.lisp Subject: Franz Lisp (at least, Opus 38.79) bug with pretty-printing Message-ID: <731@ellie.UUCP> Date: Tue, 17-Dec-85 12:54:25 EST Article-I.D.: ellie.731 Posted: Tue Dec 17 12:54:25 1985 Date-Received: Wed, 18-Dec-85 06:48:31 EST Organization: SUNY/Buffalo Computer Science Lines: 147 Keywords: Franz lisp bug