Marcus Gomes
Marcus Gomes

Reputation: 2694

How to run a test file in SBCL

I am trying to run a test file in SBCL by executing the command sbcl --load file.lisp. However, when I execute the command the file is loaded, but I can't see my program output.

By the way here is a example of a test file:

(locally
    (declare #+sbcl(sb-ext:muffle-conditions style-warning))
  (handler-bind
      (#+sbcl(style-warning #'muffle-warning))
    (load "load.lisp")
 ))
(interval 5)
(interval 20)
(interval 500)

The load.lisp file, loads the source code of my program, that contains the definitions of several functions, including the interval function.

I already try other option from sbcl such as run sbcl --script file.lisp but the output is the same.

Anybody can help me with this problem? Thanks in advance.

** PRINT-OBJECT METHOD **

 (defmethod print-object ((tensor tensor) stream)
   "Implementation of the generic method print-object for the tensor data structure.
   If the tensor is a vector, prints its elements separated by a whitespace.
   If the tensor is not one of the previous cases, then for each sub-tensor of the
   first dimension, prints the sub-tensor separated from the next sub-tensor by a
   number of empty lines that is equal to the number of dimensions minus one."
  (labels ((rec (arg last-iteration)
              (cond ((null arg) nil)
                    ((atom (car arg))
                        (format stream
                                (if (null (cdr arg)) "~A" "~A ")
                                (car arg))
                        (rec (cdr arg) nil))
                    ((and (listp (car arg)) (null (cdr arg)))
                        (rec (car arg) last-iteration)
                        (unless last-iteration
                          (format stream "~%")))
                    (t
                        (rec (car arg) nil)
                        (format stream "~%")
                        (rec (cdr arg) last-iteration)))))
      (rec (tensor-content tensor) t)))

Upvotes: 3

Views: 1839

Answers (1)

m-n
m-n

Reputation: 1446

When you load a file the return values of the forms are not automatically printed.

One option out of many:

(defun show (&rest items)
  (dolist (i items)
    (prin1 i)
    (fresh-line))
  (finish-output))

(locally
    (declare #+sbcl(sb-ext:muffle-conditions style-warning))
  (handler-bind
      (#+sbcl(style-warning #'muffle-warning))
    (load "load.lisp")
 ))

(show
  (interval 5)
  (interval 20)
  (interval 500))

Should be usable with sbcl --script file.lisp.

Upvotes: 2

Related Questions