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

Scott L. Burson Scott at sympoiesis.com
Fri Nov 26 23:02:59 UTC 2010


[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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20101126/4edb9c38/attachment.html>


More information about the pro mailing list