[pro] Chains of multiple-value-bind...

Pascal Costanza pc at p-cos.net
Fri Nov 26 13:36:57 UTC 2010


Hi,

I just hacked the following macro:

(defmacro multiple-value-case (&body clauses)
  (when clauses
    (destructuring-bind (first &rest rest) clauses
      (cond ((member (first first) '(t otherwise))
             (when clauses (warn "Dead code: ~S." clauses))
             `(progn ,@(rest first)))
            (t (destructuring-bind ((&rest lambda-list) expression (guard) &rest body) first
                   `(multiple-value-bind ,lambda-list ,expression
                      (if ,guard (progn , at body)
                        (multiple-value-case , at rest)))))))))

Did anybody see anything similar before? Any suggestions for improvement?


Thanks,
Pascal

-- 
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium










More information about the pro mailing list