Path: utzoo!utgpu!attcan!uunet!cs.utexas.edu!pp!cadillac!puma!vaughan From: vaughan@puma.cad.mcc.com (Paul Vaughan) Newsgroups: comp.lang.lisp Subject: multiple values and conditionals Message-ID: <886@cadillac.CAD.MCC.COM> Date: 21 Apr 89 19:31:07 GMT Sender: news@cadillac.CAD.MCC.COM Lines: 25 This is a specification for a multiple-value handling OR construct. It behaves like the traditional OR, but returns all the values of the first form which returns a non-nil first value. (The usual OR does this only if the first such form is the last form, otherwise, it returns only the first value.) (defmacro mv-or (&rest forms) (cond ((null forms) nil) ((null (cdr forms)) (first forms)) (t (let ((values-symbol (gensym "VALUES"))) `(let ((,values-symbol (multiple-value-list ,(first forms)))) (if (car ,values-symbol) (values-list ,values-symbol) (mv-or . ,(cdr forms)))))))) I might use it in a function that did something like (defun lookup (key primary-table secondary-table) (declare (values value found found-key)) (mv-or (gethash key primary-table) (gethash key secondary-table))) Somebody please tell me why such a thing is stupid, unnecessary, or should never arise. Paul Vaughan, MCC CAD Program | ARPA: vaughan@mcc.com | Phone: [512] 338-3639 Box 200195, Austin, TX 78720 | UUCP: ...!cs.utexas.edu!milano!cadillac!vaughan