From 23db859de6fb1237802705e3ff920f67332db3d8 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 27 Apr 2022 17:53:54 -0700 Subject: factor out CONTAINER:CONTAINED-P Signed-off-by: Sean Whitton --- src/property/container.lisp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/property') diff --git a/src/property/container.lisp b/src/property/container.lisp index a269b91..042dd69 100644 --- a/src/property/container.lisp +++ b/src/property/container.lisp @@ -41,6 +41,12 @@ CHROOT:OS-BOOTSTRAPPED, rather than being added to DEFHOST forms." contained)) (:hostattrs (push-hostattrs 'iscontained contained))) +(defun contained-p (&rest contained) + "Return non-nil if we are outside of any container, or when each of CONTAINED, +a list of symbols, is contained by this container type." + (alet (get-hostattrs 'iscontained) + (or (not it) (loop for factor in contained always (member factor it))))) + (defmacro when-contained ((&rest contained) &body propapps) "Macro property combinator. Apply each of PROPAPPS only when outside of any container, or when each of CONTAINED, a list of symbols, is contained by this @@ -51,12 +57,7 @@ container type." (define-function-property-combinator when-contained* (contained propapp) (macrolet ((check-contained (form) - `(let ((host-contained (get-hostattrs 'iscontained))) - (if (or (not host-contained) - (loop for factor in contained - always (member factor host-contained))) - ,form - :no-change)))) + `(if (apply #'contained-p contained) ,form :no-change))) (:retprop :type (propapp-type propapp) :hostattrs (lambda-ignoring-args (propapp-attrs propapp)) -- cgit v1.2.3