This patch adds two variables to swank: *listener-print-level* and *listener-print-length*, analogous to the standard Lisp variables *print-level* and *print-length*, used to control how much of a form's return values get printed at the REPL but not of things printed directly by user code. If they're bound (by default, they aren't) then swank uses them when preparing the presentation of an evaluation's result for sending to Emacs. When they're unbound, the values of the standard CL depth and length variables instead.
I've written this because of one too many "oops, I forgot to wrap that form in a (progn ... nil)" mistakes on my part. Not a fatal error, but it can be inconvenient.
"Robert J. Macomber" slime@rojoma.com writes:
This patch adds two variables to swank: *listener-print-level* and *listener-print-length*, analogous to the standard Lisp variables *print-level* and *print-length*, used to control how much of a form's return values get printed at the REPL but not of things printed directly by user code. If they're bound (by default, they aren't) then swank uses them when preparing the presentation of an evaluation's result for sending to Emacs. When they're unbound, the values of the standard CL depth and length variables instead.
While I symphatize with the motivation, I also strongly disagree with this patch on two grounds:
1. *PRINT-LEVEL* &co are the right tools to use for affecting the REPL. If your code assumes magic values of *PRINT-LEVEL* it is more-or-less broken, and should bind them explicitly, for which you will find WITH-STANDARD-IO-SYNTAX convenient.
2. If this really really must go in, please let us make it *PRESENTATION-PRINT-ALIST* instead, and use a PROGV:
(let ((bindings (reverse *listener-print-alist*))) (progv (mapcar #'car bindings) (mapcar #'cdr bindings) ...))
This way when someone needs *PRINT-RADIX* or similar they don't have to add and document another variable.
Cheers,
-- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs."
On Wed, May 24, 2006 at 10:25:45AM +0300, Nikodemus Siivola wrote:
- *PRINT-LEVEL* &co are the right tools to use for affecting the REPL. If your code assumes magic values of *PRINT-LEVEL* it is more-or-less broken, and should bind them explicitly, for which you will find WITH-STANDARD-IO-SYNTAX convenient.
Well, code I write at the REPL, inasmuch as it assumes anything at all, will be assuming "default values" or "the values I just setf'd" for the printer control things. This is quick throwaway code, not production stuff, or it'd go in a file and use w-s-i-s. Anyway, the point is, these things sometimes -- frequently enough that I got sufficiently annoyed by it to write the patch -- will return a value I'm not interested in but which takes a lot of space to print (this happens pretty often when doing a quick image-manipulation with cl-gd at the repl). It's just a way to keep myself from kicking myself and saying "idiot, you should've returned nil or (values) or something so you wouldn't lose so much visual context".
That's why the default behavior is to behave as if this patch didn't exist at all. I did expect it would be nonintuitive and surprising for the REPL printer to suddenly act differently from printer calls in other places.
- If this really really must go in, please let us make it *PRESENTATION-PRINT-ALIST* instead, and use a PROGV:
Ok. New version attached.
"Robert J. Macomber" slime@rojoma.com writes:
Well, code I write at the REPL, inasmuch as it assumes anything at all, will be assuming "default values" or "the values I just setf'd" for the printer control things. This is quick throwaway code, not production stuff, or it'd go in a file and use w-s-i-s. Anyway, the point is, these things sometimes -- frequently enough that I got sufficiently annoyed by it to write the patch -- will return a value I'm not interested in but which takes a lot of space to print (this happens pretty often when doing a quick image-manipulation with cl-gd at the repl). It's just a way to keep myself from kicking myself and saying "idiot, you should've returned nil or (values) or something so you wouldn't lose so much visual context".
Let me get this straight: what goes wrong if you set *PRINT-LEVEL*, or *PRINT-LENGTH* appropriately?
Btw: for image manipulation stuff setting *PRINT-ARRAY* to NIL will probably do what you want.
- If this really really must go in, please let us make it *PRESENTATION-PRINT-ALIST* instead, and use a PROGV:
Ok. New version attached.
I'll defer to the public opinion once it makes itself heard. ;-)
Cheers,
-- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs."