 ;; distribute, sublicense, and/or sell copies of the Software, and to
 ;; permit persons to whom the Software is furnished to do so, subject to
 ;; the following conditions:
-;; 
+;;
 ;; The above copyright notice and this permission notice shall be
 ;; included in all copies or substantial portions of the Software.
-;; 
+;;
 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND


(defmacro defmethod (name premise arguments &rest forms)
  "Adds a branch to a previously-defined multi-method."
  `(multi/-make-multi-method-branch ',name ,premise
            (lambda ,arguments ,@forms)))


;; API ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro defmulti (name arguments &rest forms)
  "Defines a new multi-method and a dispatch function."
  (declare (doc-string 3)
           (debug (&define name (&rest arg) [&optional stringp] def-body))
           (indent defun))
  `(progn
     (defun ,name (&rest args)
       ,(when (stringp (car forms)) (prog1 (car forms) (setq forms (cdr forms))))
       (apply (multi/-dispatch-with ',name (lambda ,arguments ,@forms))
        args))
     (multi/-make-multi-method ',name)))
