Skip to content

Commit

Permalink
add EVAL-WHEN around compile-time-needed definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
stylewarning committed Mar 31, 2021
1 parent c97520b commit 394cf43
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/backend-function.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 394cf43

Please sign in to comment.