(defmacro defun-js (name lambda-list &body body)
(declare (ignore body))
(labels ((sym% (argspec) (if (symbolp argspec) argspec (car argspec))))
(multiple-value-bind (required optionals restp rest keyp keys allowp auxp aux morep more-context more-count beyond-requireds? key-object)
(ps::parse-lambda-list lambda-list)
(declare (ignore restp keyp allowp auxp aux morep more-context more-count beyond-requireds? key-object))
;; get rid of init forms, which can't be evaluated in Lisp.
(setf optionals (mapcar #'sym% optionals) keys (mapcar #'sym% keys))
`(defun ,name (,@required ,@(when optionals `(&optional ,@optionals))
,@(when rest `(&rest ,rest)) ,@(when keys `(&key ,@keys)))
(declare (ignore ,@required ,@optionals ,@(when rest (list rest)) ,@keys))
(error "The ~s function is js-only and cannot be called from Lisp." ',name)))))
(defpsmacro defun-js (name lambda-list &body body)
`(defun ,name ,lambda-list ,@body))