author | Alan Dipert
<alan@dipert.org> 2020-01-28 19:23:18 UTC |
committer | Alan Dipert
<alan@dipert.org> 2020-01-28 19:23:18 UTC |
parent | 57169d49b7f97e9fdae37b070f1bab2cf2e7d83a |
boot.lisp | +19 | -5 |
diff --git a/boot.lisp b/boot.lisp index 2c276ce..eb1976f 100644 --- a/boot.lisp +++ b/boot.lisp @@ -26,17 +26,19 @@ (jacl:%lambda ,params ,@body)) ',name)) -(defun %export (symbol) - (\. *package* (|exportSymbol| (\. symbol |name|)))) +(defun export (symbol &optional (package *package*)) + (\. package (|exportSymbol| (\. symbol |name|)))) + +(export 'export) (defun %instanceof (obj ctor) (%js "(~{} instanceof ~{})" obj ctor)) -(%export 'set) +(export 'set) (defun set (symbol value) (%js "(~{}.value = ~{})" symbol value)) -(%export 'defvar) +(export 'defvar) (defmacro defvar (symbol &optional (value nil value?)) `(jacl:%progn (jacl:%js "~{}.isSpecial = true" ',symbol) @@ -45,10 +47,22 @@ nil) ',symbol)) -(%export 'let) +(export 'let) (defmacro let (bindings &rest body) `(jacl:%let ,bindings ,@body)) +(export 'if) +(defmacro if (test true-form &optional else-form) + `(jacl:%if ,test ,true-form ,else-form)) + +(export 'symbolp) +(defun symbolp (x) + (jacl:%js "((~{} instanceof LispSymbol || ~{} === null) ? true : null)" x x)) + +(export 'stringp) +(defun stringp (x) + (jacl:%js "(~{} instanceof LispString ? true : null)" x)) + ;; Use COMMON-LISP from COMMON-LISP-USER and switch to ;; COMMON-LISP-USER (%let ((cl-user-pkg (\. (%js "Package") (|get| (\. '#:common-lisp-user |name|)))))