How to pprint all globals?


#1

Hi,

I want to pprint all defined items and I tried:

(mapc pprint (globals))

but this gives me only the names of each symbol, each in one line, and at the end the first item pprinted.

Is it possible to print out all function definitions with one command (or one function)?

Thanks,
Kaef


Ulisp-2.4-esp with 4 MByte PSRAM support
#2

Sorry, last post was wrong. The result is the items each in one line, returning a list with all items.


#3

What you want is:

(defun pp ()
  (mapc 
   (lambda (x) (pprint (eval x)) (terpri))
   (globals))
  nothing)

Run it by typing:

(pp)

Alternatively, a fancier version that prints each definition starting with defun is:

(defun pp ()
  (mapc 
   (lambda (x)
     (let ((v (eval x)))
       (unless (eq x 'pp)
         (when (eq (car v) 'lambda)
           (pprint (cons 'defun (cons x (cdr v)))))
         (terpri))))
   (globals))
  nothing)

#4

Yes, that’s what I wanted, thank you very much!


#5

As of uLisp Version 2.3 this feature is now built in to uLisp, using the function:

(pprintall)