christian wuensche
christian wuensche

Reputation: 1043

sbcl parse and execute immediately with --script

if I run the following common lisp code:

(print "A")
(print "B")
(print "C - No closing bracket"

sbcl --script ./test.lisp

A and B are printed. And after that the error appears like expected.

Does SBCL parses the first line(s) (or in other words "bracket enclosed code") and immediately execute it before going to the next part? Or does it parses the whole file and "mark" that there is a parser error at a specific point in the AST?

Upvotes: 1

Views: 133

Answers (1)

ignis volens
ignis volens

Reputation: 9252

It reads things form by form, in the same way that load, compile etc do. It's doing something like this (but more complicated):

(defun trivial-script-runner (f)
  (let ((*package* *package*))
    ;; ... and other things
    (with-open-file (in f)
      (loop for form = (read in nil in)
            until (eq form in)
            do (eval form)))))

Upvotes: 6

Related Questions