diff --git a/box.lisp b/box.lisp index ac5a5cc..bb72709 100644 --- a/box.lisp +++ b/box.lisp @@ -26,11 +26,7 @@ accessor `unbox'. Serapeum attempts to provide the guarantee that, on Lisps that support atomic operations (compare-and-swap), `unbox` on boxes should be updateable atomically. (See -[atomics](https://github.com/Shinmera/atomics)). - -At the moment, boxes are implemented as structures, but that may -change. In particular, you should not depend on being able to -recognize boxes using a type or predicate." +[atomics](https://github.com/Shinmera/atomics))." unbox) (declaim-freeze-type box) @@ -60,3 +56,8 @@ recognize boxes using a type or predicate." (typep ,b 'box) (unbox ,b) ,x))) + +(-> ensure-box (t) box) +(defun ensure-box (x) + "Return X if boxed, otherwise a box containing X." + (if (boxp x) x (box x))) diff --git a/package.lisp b/package.lisp index 92f91cf..78b849e 100644 --- a/package.lisp +++ b/package.lisp @@ -383,6 +383,7 @@ ;; Boxes. #:box #:unbox + #:ensure-box ;; Heaps. #:make-heap #:heap-insert