X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/blobdiff_plain/1af04ae56277989d39b46f5924c8f8a90bf4c6e0..c72e87d8951cdb4bf9315c2dfae99b99d91a3a60:/src/lib/js-utils.lisp diff --git a/src/lib/js-utils.lisp b/src/lib/js-utils.lisp index 5644972..5e413bd 100644 --- a/src/lib/js-utils.lisp +++ b/src/lib/js-utils.lisp @@ -37,7 +37,24 @@ (defpsmacro ignore-errors (&body body) `(try (progn ,@body) (:catch (e)))) +;;; Data structures + +(defpsmacro length (a) + `(.size ,a)) + ;;; Misc (defpsmacro null (x) `(= ,x nil)) + +(defpsmacro @ (obj &rest props) + "Handy slot-value/aref composition macro." + (if (null props) + obj + `(@ (slot-value + ,(if (stringp obj) `($ ,obj) obj) + ,(let ((prop (macroexpand (first props)))) + (if (symbolp prop) + `',prop + prop))) + ,@(cdr props)))) \ No newline at end of file