git » jacl.git » commit 183d28d

boot.lisp

author Alan Dipert
2020-02-06 00:07:10 UTC
committer Alan Dipert
2020-02-06 00:07:10 UTC
parent e262846986ac24ef6780cfd46595ad8d3cc20706

boot.lisp

boot.lisp +29 -2

diff --git a/boot.lisp b/boot.lisp
index 0461dfb..16c001a 100644
--- a/boot.lisp
+++ b/boot.lisp
@@ -174,17 +174,43 @@
 (defun listp (x)
   (or (null x) (consp x)))
 
-(defun designated-string (x)
+(%export 'lambda)
+(defmacro lambda (params &rest body)
+  `(jacl:%lambda ,params ,@body))
+
+(defun %designated-string (x)
   (cond ((stringp x) x)
         ((symbolp x)
          (jacl:\. (jacl:%js "LispString") (|fromString| (jacl:\. x |name|))))
         (t (%type-error "string or symbol"))))
 
-(defun designated-symbols (x)
+(defun %designated-symbols (x)
   (cond ((symbolp x) (list x))
         ((listp x) x)
         (t (%type-error "symbol or list of symbols"))))
 
+(%export 'let*)
+(defmacro let* (bindings &rest body)
+  (if bindings
+      `(let (,(car bindings))
+         (let* ,(cdr bindings)
+           ,@body))
+      `(progn ,@body)))
+
+(%export 'function)
+(defmacro function (x)
+  `(jacl:%js "~{}.func()" x))
+
+(%export 'functionp)
+(defun functionp (x)
+  (jacl:%js "~{} instanceof Function ? true : null" x))
+
+(%export 'funcall)
+(defun funcall (f &rest args)
+  (when (not (functionp f))
+    (%type-error "function"))
+  (jacl:%js "~{}.call(null, List.toArray(~{}))" f args))
+
 ;; TODO
 (%export 'export)
 (defun export (symbols &optional (package *package*))
@@ -201,3 +227,4 @@
 (%let ((cl-user-pkg (\. (%js "Package") (|get| (\. '#:common-lisp-user |name|)))))
   (\. cl-user-pkg (|usePackage| cl:*package*))
   (%setq cl:*package* cl-user-pkg))
+