New functions: copy-list, identity
[jscl.git] / ecmalisp.lisp
index e4dba1b..be51b2d 100644 (file)
         (cons (funcall func (car list))
               (mapcar func (cdr list)))))
 
+  (defun identity (x) x)
+
+  (defun copy-list (x)
+    (mapcar #'identity x))
+
   (defun code-char (x) x)
   (defun char-code (x) x)
   (defun char= (x y) (= x y))
     (push (concat "var " (binding-translation b)) *toplevel-compilations*)))
 
 (defun %compile-defun (name)
-  (let ((b (lookup-function name *env*)))
+  (let ((b (lookup-function name *fenv*)))
     (mark-binding-as-declared b)
     (push (concat "var " (binding-translation b)) *toplevel-compilations*)))
 
     "eval.apply(window, [string])"))
 
 (define-builtin error (string)
-  (concat "(function (){ throw " string ";" "return 0;})()"))
+  (concat "(function (){ throw " string "; })()"))
 
 (define-builtin new () "{}")
 
         (setq *compilation-unit-checks* nil))))
 
   (defun bootstrap ()
+    (setq *variable-counter* 0
+          *gensym-counter* 0
+          *function-counter* 0
+          *literal-counter* 0)
     (ls-compile-file "ecmalisp.lisp" "ecmalisp.js")))