>>>>> On Fri, 26 Nov 2010 14:36:57 +0100, Pascal Costanza said: > > 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 ,@body) > (multiple-value-case ,@rest))))))))) > > Did anybody see anything similar before? Any suggestions for improvement?
I am confused about why guard has parens around it. It might be better to group the guard and the body like cond does, i.e. (destructuring-bind ((&rest lambda-list) expression (guard &rest body)) first Also the nesting of the multiple-value-binds in the expansion leads to unexpected lexical scoping. Maybe if you call it multiple-value-cond* ... -- Martin Simmons LispWorks Ltd http://www.lispworks.com/ _______________________________________________ pro mailing list [email protected] http://common-lisp.net/cgi-bin/mailman/listinfo/pro
