From c1fbc5ab70c5be3eba3d451e37fbc896dcb7e2ce Mon Sep 17 00:00:00 2001 From: Gerd Heber Date: Sat, 8 Aug 2015 09:12:49 -0500 Subject: [PATCH] Added DEF macro to define dynamic variables in user space and get around the 'undefined variable' warnings when using SETF without prior variable declaration. --- package.lisp | 1 + src/macros.lisp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/package.lisp b/package.lisp index 9ea85c1..42b1442 100644 --- a/package.lisp +++ b/package.lisp @@ -405,6 +405,7 @@ CPRD CRPR D + DEF F DFFR DGNL diff --git a/src/macros.lisp b/src/macros.lisp index b6c27b0..fae82f5 100644 --- a/src/macros.lisp +++ b/src/macros.lisp @@ -6,6 +6,25 @@ (PROVIDE "macros") + +;;; +;;; UTILITIES + + +(defmacro def (name value) + (declare (type symbol name)) + "-----------------------------------------------------------------[macro-doc] +DEF +Args: (name value) +Defines a dynamic variable NAME in the CL-USER package, assigns it VALUE, +and returns VALUE. +------------------------------------------------------------------------------" + `(progn + (intern (symbol-name ',name)) + (defparameter ,name nil) + (setq ,name ,value))) + + ;;; ;;; VARIOUS ;;;