mwal
mwal

Reputation: 3123

Load functions from file into REPL - Continuable Error

Up to now in my Lisp adventures I've just been pasting functions as written in a code editor into the REPL to run them, but I now have a program of sufficient size to build on that it will be convenient to use (load "filename.lisp") for the first time in my workflow.

Must I start using packages and/or namespacing to achieve this?

I find that when I use load, as above, I get

** - Continuable Error
DEFUN/DEFMACRO(CLASS): #<PACKAGE CLOS> is locked
If you continue (by typing 'continue'): Ignore the lock and proceed
The following restarts are also available:
SKIP           :R1      skip (DEFMACRO CLASS # ...)
RETRY          :R2      retry (DEFMACRO CLASS # ...)
STOP           :R3      stop loading file /Users/m/cl/ansi-cl/ch17-objects/177d-new-full.lisp
ABORT          :R4      Abort main loop

My .lisp file contains a macro called class, so I understand the error, sort of.

The thing is, when I paste the contents of the file directly into the REPL, I get no such error.

What's causing the difference in behaviour? Is it packages, namespaces or something else?

I can indeed just type continue, and the file will load, but I'd like to understand what is happening here; what's the cause of this "Continuable error", and how should I deal with it if at all?

Upvotes: 0

Views: 282

Answers (1)

sds
sds

Reputation: 60074

Package locking in CLISP is explained in the manual.

Symbol class is an ANSI CL symbol, so it cannot name any user-defined entity, and thus your program is not conforming, as explained in 11.1.2.1.2 Constraints on the COMMON-LISP Package for Conforming Programs. You should rename your macro.

The lack of the error in the REPL is a bug in homebrew clisp. CLISP as distributed with ubuntu works correctly. When I build CLISP from sources on Mac, it works correctly too.

Upvotes: 4

Related Questions