Steel Bank Common Lisp

TRACE :PRINT doesn't handle multiple values

Reported by Leslie P. Polzer on 2009-10-21
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Wishlist
Unassigned

Bug Description

This is SBCL 1.0.31.26, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
CL-USER(1): (defun foo nil)

FOO
CL-USER(2): (trace :print (values 1 2) foo)

(FOO)
CL-USER(3): (foo)
  0: (FOO)
  0: (VALUES 1 2) = 1
  0: FOO returned NIL
NIL
CL-USER(4):

I expected to see both values.

Nikodemus Siivola (nikodemus) wrote :

From TRACE docstring:

       :PRINT Form
       :PRINT-AFTER Form
       :PRINT-ALL Form
           In addition to the usual printout, the result of evaluating Form is
           printed at the start of the function, at the end of the function, or
           both, according to the respective option. Multiple print options cause
           multiple values to be printed.

So, this behaviour is by design as far as I can tell. (If there are good use-case for handling multiple values, please file a new bug describing the desired functionality.)

Changed in sbcl:
status: New → Confirmed
importance: Undecided → Low
status: Confirmed → Invalid
status: Invalid → Confirmed
importance: Low → Wishlist
status: Confirmed → Invalid
importance: Wishlist → Undecided
Leslie P. Polzer (polzer-gnu) wrote :

Sorry, I don't get how the quoted paragraph pertains to multiple values as defined by the spec.
All it seems to say is that multiple :PRINT options cause multiple forms to be evaluated and their result printed.

Do you mean something else?

Nikodemus Siivola <email address hidden> writes:

> So, this behaviour is by design as far as I can tell. (If there are good
> use-case for handling multiple values, please file a new bug describing
> the desired functionality.)

 status confirmed
 importance wishlist
 tag trace easy
 done

I can come up with a use-case: what about using trace to view the state
of a hashtable before and after a function call: something like

  (trace foo :print-all (gethash 'key *table*))

It would be quite annoying for NIL to be printed, and then having to
worry about whether that actually means "key not present" or "key has
associated value NIL in *table*".

Christophe

Changed in sbcl:
importance: Undecided → Wishlist
status: Invalid → Confirmed
Matthias Benkard (mulk) wrote :

Hi,

I've written a next to trivial patch for this. Seems to work. :)

SB-DEBUG> (defvar *table* (make-hash-table))
*TABLE*
SB-DEBUG> (defun foo () (setf (gethash 'key *table*) 123))
FOO
SB-DEBUG> (trace foo :print-all (gethash 'key *table*))
(FOO)
SB-DEBUG> (foo)
  0: (FOO)
  0: (GETHASH 'KEY *TABLE*) = NIL, NIL
  0: FOO returned 123
  0: (GETHASH 'KEY *TABLE*) = 123, T
123

Stas Boukarev (stassats) wrote :

Use "~@<~S ~_= ~:[; No values~;~:*~{~S~^, ~}~]~:>" instead, so that when no values is returned it's easier to see that.
Add a NEWS entry, something like "enhancement: commit-message. (lp#457053)." at the top.

Stas Boukarev (stassats) wrote :

And mention the ticket in the commit message. Something like "Closes lp#457053." at the end.

Matthias Benkard (mulk) wrote :

Thanks for the feedback!

Second try. :)

Stas Boukarev (stassats) wrote :

Thanks, applied.

Changed in sbcl:
status: Confirmed → Fix Committed
Stas Boukarev (stassats) wrote :

commit d4345a2363f9cbf440e6a5d52f8451c4f903cefd
Author: Matthias Andreas Benkard <email address hidden>
Date: Tue Apr 16 16:53:00 2013 +0200

    Handle multiple-valued forms in TRACE :PRINT.

Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers