decls)
(concat "return " (progn ,@body) ";" *newline*)))
-;;; VARIABLE-ARITY compiles variable arity operations. ARGS stand for
+;;; VARIABLE-ARITY compiles variable arity operations. ARGS stands for
;;; a variable which holds a list of forms. It will compile them and
;;; store the result in some Javascript variables. BODY is evaluated
;;; with ARGS bound to the list of these variables to generate the
(concat "return " ,@body ";" *newline*))))
+(define-raw-builtin + (&rest numbers)
+ (variable-arity numbers
+ (join numbers "+")))
+
+(define-raw-builtin - (x &rest others)
+ (let ((args (cons x others)))
+ (variable-arity args
+ (if (null others)
+ (concat "-" (car args))
+ (join args "+")))))
+
+
(defun num-op-num (x op y)
(type-check (("x" "number" x) ("y" "number" y))
(concat "x" op "y")))
-(define-builtin + (x y) (num-op-num x "+" y))
-(define-builtin - (x y) (num-op-num x "-" y))
(define-builtin * (x y) (num-op-num x "*" y))
(define-builtin / (x y) (num-op-num x "/" y))