From: David Vazquez Date: Mon, 17 Dec 2012 16:58:30 +0000 (+0000) Subject: make-symbol and intern X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=370dbb9ff46bd350e178b733ab9ea1d6f7b9a1da;p=jscl.git make-symbol and intern --- diff --git a/lispstrack.lisp b/lispstrack.lisp index f3f01df..3f85b93 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -50,7 +50,16 @@ (mapcar func (cdr list))))) (defmacro push (x place) - `(setq ,place (cons ,x ,place)))) + `(setq ,place (cons ,x ,place))) + + + (defvar *package* (new)) + + (defun intern (name) + (set *package* name (make-symbol name))) + + (defun find-symbol (name) + (get *package* name))) (defun !reduce (func list initial) @@ -454,6 +463,9 @@ (define-compilation cdr (x) (concat "(" (ls-compile x env fenv) ").cdr")) +(define-compilation make-symbol (name) + (concat "{name: " (ls-compile name env fenv) "}")) + (define-compilation symbol-name (x) (concat "(" (ls-compile x env fenv) ").name")) @@ -490,6 +502,18 @@ ", ") ")")) +(define-compilation new () + "{}") + +(define-compilation get (object key) + (concat "(" (ls-compile object env fenv) ")[" (ls-compile key env fenv) "]")) + +(define-compilation set (object key value) + (concat "(" (ls-compile object env fenv) ")[" (ls-compile key env fenv) "]") + " = " (ls-compile value env fenv)) + + + (defun %compile-defvar (name) (push (make-var-binding name) *env*) (push (concat "var " (lookup-variable name *env*)) *toplevel-compilations*)) diff --git a/test.lisp b/test.lisp deleted file mode 100644 index 7635aaa..0000000 --- a/test.lisp +++ /dev/null @@ -1 +0,0 @@ -;;; Library