From 2403f5c0a09915cd1100159953fa8430f0417ced Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 17 Mar 2021 19:11:24 -0700 Subject: record which symbols are properties at compile time This is for the sake of PROPS. Signed-off-by: Sean Whitton --- src/property.lisp | 7 ++++--- src/propspec.lisp | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/property.lisp b/src/property.lisp index d8c1493..04d3780 100644 --- a/src/property.lisp +++ b/src/property.lisp @@ -47,11 +47,10 @@ (setf (get sym 'papply) apply)) (when unapply (setf (get sym 'unapply) unapply)) - (setf (get sym 'property) t) sym) (defun isprop (prop) - (and (symbolp prop) (get prop 'property nil))) + (and (symbolp prop) (get prop 'isprop nil))) (defun proptype (prop) (get prop 'ptype)) @@ -110,6 +109,7 @@ This variable exists just to avoid consing these forms over and over again; see MAP-PROPSPEC-PROPAPPS for how they are used.") (defun record-known-property (psym) + (setf (get psym 'isprop) t) (push psym *known-properties*) (push `(,psym (&rest args) (let ((gensym (gensym))) @@ -222,7 +222,8 @@ parsing FORMSV and pushing SETPROP keyword argument pairs to plist SLOTSV." (let ((indent (cadr (assoc 'indent (cdar ,declarations))))) ,@mforms `(progn - (record-known-property ',,name) + (eval-when (:compile-toplevel :load-toplevel :execute) + (record-known-property ',,name)) (store-indentation-info-for-emacs ',,name ',,lambdav ,indent) (setprop ',,name ,@,slotsv) ;; TODO Ideally we would use ,(ordinary-ll-without-&aux diff --git a/src/propspec.lisp b/src/propspec.lisp index f295081..c51b7df 100644 --- a/src/propspec.lisp +++ b/src/propspec.lisp @@ -109,17 +109,17 @@ arguments to properties in propapps, but that should not be needed." (error () (error 'invalid-or-ambiguous-propspec :propspec propspec))))) ;; Now we use a dummy macro expansion pass to find any symbols without - ;; function definitions occurring in function call positions. These - ;; could potentially be properties whose definitions have not been - ;; loaded -- especially since we get called at compile time by PROPS -- - ;; and if so, we would return an incorrect result because the previous - ;; step will not have identified all the propapps in the propspec. So - ;; error out if we detect that situation. + ;; function or property definitions occurring in function call + ;; positions. These could potentially be properties whose definitions + ;; have not been loaded -- especially since we get called at compile + ;; time by PROPS -- and if so, we would return an incorrect result + ;; because the previous step will not have identified all the propapps + ;; in the propspec. So error out if we detect that situation. (macrolet-and-expand (loop for leaf in (delete-duplicates (flatten expanded)) if (and (symbolp leaf) (not (isprop leaf))) collect `(,leaf (&rest args) - (unless (fboundp ',leaf) + (unless (or (fboundp ',leaf) (isprop ',leaf)) (error 'ambiguous-propspec :name ',leaf)) ;; return something which looks like an ;; ordinary function call to the code walker, -- cgit v1.2.3