Re: (case 'quote ('lambda 1) (otherwise 2))
- From: tayssir.john@xxxxxxxxxxxxxx
- Date: 29 Jan 2007 21:44:15 -0800
On Jan 29, 11:57 pm, Pascal Bourguignon <p...@xxxxxxxxxxxxxxxxx>
wrote:
Now, when you try these read-from-string forms, you must be careful
not to be misled by your implementation printer, which usually process
specially lists such as (QUOTE X) and (FUNCTION X) and print them as
'X and #'X instead of printing them as normal lists. To be sure, you
can use your own list printing function:
Hmm, maybe I should use something similar when I want things to pretty-
print like (function ...) rather than #'.... (Say, in a quick 'n dirty
logfile thing, where #'... did once annoy me.)
;; Bind this to nil if you want sourcecode to be printed using a style
like
;; (function ...) rather than #'...
(defvar *print-code-fancily* t)
(defun length-2? (x) (= 2 (length x)))
;; Installs pretty-print dispatchers for FUNCTION and QUOTE forms.
(flet ((set-pprint-dispatch... (type original-dispatcher)
(set-pprint-dispatch
` (and (cons (eql ,type))
(satisfies length-2?))
(lambda (s list)
(if *print-code-fancily*
(funcall original-dispatcher s list)
(funcall (formatter "~:<~W ~_~W~:>") s list))))))
(set-pprint-dispatch... 'function
(pprint-dispatch '(function x)
(copy-pprint-dispatch
nil)))
(set-pprint-dispatch... 'quote
(pprint-dispatch '(quote x)
(copy-pprint-dispatch
nil))))
Keep in mind I've almost never messed with the pretty-printer before..
Tayssir
--
Anarchism and the Academy:
http://mbanna.radio4all.net/pub/archive5/mp3_4/200108-renew-acad-p.mp3
http://mbanna.radio4all.net/pub/archive5/mp3_4/200108-renew-acad-q.mp3
.
- Follow-Ups:
- Re: (case 'quote ('lambda 1) (otherwise 2))
- From: tayssir . john
- Re: (case 'quote ('lambda 1) (otherwise 2))
- References:
- (case 'quote ('lambda 1) (otherwise 2))
- From: David Wragg
- Re: (case 'quote ('lambda 1) (otherwise 2))
- From: Pascal Bourguignon
- (case 'quote ('lambda 1) (otherwise 2))
- Prev by Date: Re: All Your GUIs Are Belong to Us (Die, McCLIM! Die!!)
- Next by Date: Automatic parallelization - was Re: LISP Object Oriented?
- Previous by thread: Re: (case 'quote ('lambda 1) (otherwise 2))
- Next by thread: Re: (case 'quote ('lambda 1) (otherwise 2))
- Index(es):
Relevant Pages
|