Add export to common lisp form, forms
[clnl] / src / main / nvm / base.lisp
index 9d07e9b1280ff677b51faf1e65993f924c59cc80..af87bc27e167f68c320a51009d59087bb22b60d6 100644 (file)
@@ -7,10 +7,28 @@
 (defvar *myself* nil)
 (defvar *self* nil)
 (defvar *dimensions* nil)
+(defvar *globals* nil)
 (defvar *topology* :torus)
 (defvar *ticks* nil)
 (defvar *breeds* nil)
 
+(define-condition stop nil nil)
+
+(defmacro with-stop-handler (&rest forms)
+ "MACRO WITH-STOP-HANDLER &rest FORMS => HANDLED-FORM
+
+ARGUMENTS AND VALUES:
+
+  FORMS: body to be handled
+  HANDLED-FORM: body with handling
+
+DESCRIPTION:
+
+  WITH-STOP-HANDLER is a convenience macro to handle when
+  programs issue a stop condition.  When one does, a simple
+  :stop is returned."
+ `(handler-case (progn ,@forms) (stop (s) (declare (ignore s)) :stop)))
+
 (defstruct turtle who color heading xcor ycor (label "") (label-color 9.9d0) (size 1d0) shape)
 (defstruct patch color xcor ycor)