X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=clnl;a=blobdiff_plain;f=src%2Fmain%2Fmain.lisp;h=09244a02229c2f11e8c54799557cef8dae6985a3;hp=b6cce463cf762402adfa246bbdad7c6959a67ef0;hb=b4f2bfd8e590105c4ea65e6a5751edf0dc422aa2;hpb=72aabe56a7bfdb598d48c16c5095a0eac2420595 diff --git a/src/main/main.lisp b/src/main/main.lisp index b6cce46..09244a0 100644 --- a/src/main/main.lisp +++ b/src/main/main.lisp @@ -1,5 +1,26 @@ (in-package #:clnl) +(defvar *model-package* (find-package :cl-user) + "*MODEL-PACKAGE* + +VALUE TYPE: + + a package + +INITIAL VALUE: + + The common-lisp-user package + +DESCRIPTION: + + *MODEL-PACKAGE* is used for interning symbols as a NetLogo code + gets compiled. + + Any local symbols are interned in this package, for use either + by other code, or in order to have all symbols interned in the + same placakge. This is also the package in which a model should + be run, whether by clnl code or independently.") + (defun e (ast) ast) (defun r (str) @@ -47,7 +68,7 @@ DESCRIPTION: ((netlogoed-lisp (model->lisp (if file (with-open-file (str file) (clnl-model:read-from-nlogo str)) (clnl-model:default-model)))) - (*package* (find-package :cl))) + (*package* *model-package*)) (eval netlogoed-lisp))) (defun run-commands (cmds) @@ -82,7 +103,8 @@ DESCRIPTION: ; The intention of this method is to generate the common lisp equivalent of a model file, ; such that if you decided to no longer use nlogo, you could use the engine without it. (defun model->lisp (model) - `(progn + `(let + ,(clnl-model:globals model) (clnl-random:set-seed 15) ; should the seed always be 15? (clnl-nvm:create-world :dims ',(clnl-model:world-dimensions model)) (clnl-interface:initialize :dims ',(clnl-model:world-dimensions model))))