[pro] Chains of multiple-value-bind...
[Sorry for the dup, Pascal. Meant to send this to the whole list.] On Fri, Nov 26, 2010 at 5:36 AM, Pascal Costanza <pc@p-cos.net> wrote:
Did anybody see anything similar before? Any suggestions for improvement?
My `bcond' macro, which works closely with my `nlet' macro, attempts to solve the same problem. `nlet' subsumes `multiple-value-bind': (nlet ((a b (foo))) (bar a b)) Coming up with a good syntax for `bcond' wasn't easy, and I'm not sure what you'll think of my solution, but here it is. It's like `cond', except that if the test subform is an `nlet' form, the scope of the bindings it establishes is magically extended to included the entire clause. E.g.: (bcond ((nlet ((a b (foo))) (test a b)) (do-something a b)) ... more clauses ...) The expansion is careful not to extend the scope of the bound variables over the following clauses. These macros are in my "misc-extensions" project on common-lisp.net, included in LibCL and Quicklisp. As they are upward-compatible with `cl:let' and `cl:cond', the package provides the same macros under the names `let' and `cond', which can be shadowing-imported if desired (I use them this way). `nlet' also subsumes and generalizes `let*'. BTW I wrote these 30 years ago, in ZetaLisp. I've always made heavy use of multiple values in my style, and `multiple-value-bind' is way too inconvenient to use -- the name is too long and it only takes one binding clause at a time. -- Scott
participants (1)
-
Scott L. Burson