Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

tpapp/cl-print-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

IMPORTANT This library is abandonned.

print-debug: a Common Lisp debug library using print statements

print-debug is a simple, lightweight Common Lisp library with the purpose of facilitating debugging using print statements.

Common Lisp has excellent debugging and condition facilities, and thus print statements are usually not the best way to go, however, they have their nice. I wrote up this package when I was working on the low-level memory routines of LLA, where a mistake in memory access would occasionally kill the Lisp process, so I could not use anything else but had to rely on printet output.

It is recommended that you do not use the print-debug package, but rely on its nickname pide.

Available functionality

pide:d works like cl:format, except for three things:

  1. it does not take a first argument, as everything goes to *error-output*,
  2. it prints a timestamp first,
  3. a closing newline is appended.
(pide:d "what a nice integer: ~d" 42)

prints something like

14:16:48 what a nice integer: 42

pide:v prints form/value pairs, with :/ introducing line breaks:

(let ((a 1)
      (b 2))
  (pide:v a b :/ (+ a b)))

prints something like

14:26:47 A=1 B=2
         (+ A B)=3

pide:p prints its argument and its value, also returning the latter:

(pide:p (+ 1 2)) ; evaluates to 3

and prints

14:23:49 (+ 1 2) =>
14:23:49     => 3

It also takes an optional label as its second argument. It should allow wrapping an S-expression without too much source code editing.

Finally, pide:s saves the value (using cl:defparameter), then returns it:

(let ((v (pide:s *myvar* 1)))
  (list *myvar* v)) ; evaluates to (1 1)

It also understands multiple values, just use (pide:s (values ...) form).

About

Common Lisp debug library using print statements

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published