- ;; The representation of the current OPTIMIZE policy.
- (cookie *default-cookie* :type cookie)
- ;; the policy that takes effect in XEPs and related syntax parsing
- ;; functions. Slots in this cookie may be null to indicate that the
- ;; normal value in effect.
- (interface-cookie *default-interface-cookie* :type cookie)
- ;; an alist of miscellaneous options that are associated with the
- ;; lexical environment
- (options nil :type list))
+ ;; the current OPTIMIZE policy
+ (policy *policy* :type policy))
+
+;;; support for the idiom (in MACROEXPAND and elsewhere) that NIL is
+;;; to be taken as a null lexical environment
+(defun coerce-to-lexenv (x)
+ (etypecase x
+ (null (make-null-lexenv))
+ (lexenv x)))
+
+;;; Is it safe to just grab the lambda expression LAMBDA in isolation,
+;;; ignoring the LEXENV?
+;;;
+;;; Note: The corresponding CMU CL code did something hairier so that
+;;; it could save inline definitions of DEFUNs in nontrivial lexical
+;;; environments. If it's ever important to try to do that, take a
+;;; look at the old CMU CL #'INLINE-SYNTACTIC-CLOSURE.
+(defun lambda-independent-of-lexenv-p (lambda lexenv)
+ (declare (type list lambda) (type lexenv lexenv))
+ (aver (eql (first lambda) 'lambda)) ; basic sanity check
+ ;; This is a trivial implementation that just makes sure that LEXENV
+ ;; doesn't have anything interesting in it. A more sophisticated
+ ;; implementation could skip things in LEXENV which aren't captured
+ ;; by LAMBDA, but this implementation doesn't try.
+ (and (null (lexenv-blocks lexenv))
+ (null (lexenv-tags lexenv))
+ (null (lexenv-vars lexenv))
+ (null (lexenv-funs lexenv))))