diff --git a/src/backend-function.lisp b/src/backend-function.lisp index 29a18015..5ae1b5e4 100644 --- a/src/backend-function.lisp +++ b/src/backend-function.lisp @@ -90,26 +90,32 @@ Without using this, a backend function may error if no method is found." ;;; Backend Names -(defvar *known-backends* '() - "A list of known backends.") - -(defun backend-name-p (x) - (and (symbolp x) - (find x *known-backends*) - t)) - -(deftype backend-name () - '(satisfies backend-name-p)) +;;; Eval at compile-time because DEFINE-BACKEND and the DEFTYPE below +;;; will need it for proper expansion later in the file. +;;; +;;; (h/t phoe 3/31/21) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defvar *known-backends* '() + "A list of known backends.") -(defvar *backend* '() - "A list in priority order the backends that MAGICL should use for functionality. + (defvar *backend* '() + "A list in priority order the backends that MAGICL should use for functionality. It is preferable to use WITH-BACKENDS instead of this.") + + (defun backend-name-p (x) + (and (symbolp x) + (find x *known-backends*) + t)) +) ; EVAL-WHEN (defun active-backends () "Return a list of the active backends in priority order. Useful for debugging." *backend*) +(deftype backend-name () + '(satisfies backend-name-p)) + (defmacro define-backend (name &key documentation (default nil)) "Define the existence of a backend named NAME. If DEFAULT is T, then add it to the list of default backends."