Home > front end >  sbcl parse and execute immediately with --script
sbcl parse and execute immediately with --script

Time:12-05

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?

CodePudding user response:

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)))))
  • Related