[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Legacy caar to cddddr

 | Date: Sat, 22 Oct 2011 21:15:59 +0200
 | From: Denis Washington <denisw@x>
 | ...
 | Also, a destructuring let form would be a much better solution.
 | For instance, in Clojure you can write something like:
 | (let [[_ specs end & body] exp]
 |    ...)
 | We could have something similar in WG2:
 | (let (((_ specs end . body) exp))
 |    ...)
 | Even better, we could also have an "if-let" form whose execution
 | path depends on whether the destructuring is possible:
 | (if-let (((_ specs end . body) exp))
 |    ...
 |    (syntax-error))

How does destructuring work with mutation?  Does assigning to a bound
variable alter the matched structure?

Writing calls to SET-CAR! and SET-CDR! would require binding the pair
containing the pointer to be changed.  That would destroy the
obviousness of destructuring, but is easy to deal with using C*R: just
remove the first character after the "C" (CR is the identity

 | Such destructuring forms would remove most reasons for having cadr
 | etc. in the standard.

I disagree.

Scheme-reports mailing list