-(defun interleave (list element &optional after-last-p)
- (unless (null list)
- (with-collect
- (collect (car list))
- (dolist (x (cdr list))
- (collect element)
- (collect x))
- (when after-last-p
- (collect element)))))
-
-(defun code (&rest args)
- (mapconcat (lambda (arg)
- (cond
- ((null arg) "")
- ((integerp arg) (integer-to-string arg))
- ((floatp arg) (float-to-string arg))
- ((stringp arg) arg)
- (t
- (with-output-to-string (*standard-output*)
- (js-expr arg)))))
- args))
-
-;;; Concatenate the arguments and wrap them with a self-calling
-;;; Javascript anonymous function. It is used to make some Javascript
-;;; statements valid expressions and provide a private scope as well.
-;;; It could be defined as function, but we could do some
-;;; preprocessing in the future.
-(defmacro js!selfcall (&body body)
- ``(call (function nil (code ,,@body))))
-
-
-;;; Like CODE, but prefix each line with four spaces. Two versions
-;;; of this function are available, because the Ecmalisp version is
-;;; very slow and bootstraping was annoying.
+(define-js-macro selfcall (&body body)
+ `(call (function () ,@body)))
+
+(define-js-macro bool (expr)
+ `(if ,expr ,(convert t) ,(convert nil)))
+
+(define-js-macro method-call (x method &rest args)
+ `(call (get ,x ,method) ,@args))