From 98b5811d8b50d20f8c15e9b202f0d3f0457df58b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 30 Jun 2022 09:29:28 -0500 Subject: [modify] affine fns are generic; [add] safe-slot util --- src/utils.lisp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/utils.lisp') diff --git a/src/utils.lisp b/src/utils.lisp index e0f6dcd..3598ec3 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -7,3 +7,10 @@ (defun radians (degrees) "Converse DEGREES to radians" (* degrees +pi-over-180+)) + +(defun safe-slot (object slot &optional default) + (if-let (val (and (slot-exists-p object slot) + (slot-boundp object slot) + (slot-value object slot))) + val + default)) -- cgit v1.2.3