2015-09-04 2:54 GMT+02:00 Mark H Weaver : > Panicz Maciej Godek writes: > > > It is not a patch though, but just a separate module called (ice-9 > > nice-9) that is meant to be placed in the "ice-9" directory (e.g. > > "/usr/share/guile/2.0/ice-9"). > > > > It would definitely need a more elaborate documentation, but the quick > > note is that it: > > > > * allows to destructure arguments to lambda, e.g. > > > > (map (lambda ((a . b)) (+ a b)) '((1 . 2)(3 . 4)(5 . 6))) > > > > * blends named-let with match-let and srfi-71-style let for multiple > > values, legalizing usages like > > > > (let loop ((a (b c) (values 1 (list 2 3)))) > > ... > > (loop (values 4 (list 5 6)))) > > I only just recently noticed this message, but before people start > writing a lot of code like this, I should warn you that in the procedure > call (loop (values 4 (list 5 6))), by the semantics of Guile, that is > supposed to be equivalent to (loop 4). If it does something else, > that's probably a bug in our optimizer, and it might well act > differently on our master branch already, because the multiple-values > stuff has been cleaned up a lot compared with 2.0. Anyway, you > certainly should not rely on this behavior. Sorry... Actually, the code is written in such way that "loop" is actually a macro such that (loop (values 4 (list 5 6))) would expand to (loop* (values->list (values 4 (list 5 6)))) where loop* takes lists as inputs and (values->list call) is a syntax defined as (call-with-values (lambda () call) list), so I think it is a proper Scheme code which does not rely on any undefined behaviors. It has some drawbacks -- among others, that loop is no longer first class (although it could be made obtainable easily) and the resulting code is rather inefficient, but it ought to behave properly. There's also a comment in the module that ;; it should generally be discouraged to use the plain let ;; with multiple values, because there's no natural way to implement ;; that when there's more than one (multiple-value) binding, ;; but it's added for completeness but for the time being I've actually only been using let* with multiple values. -- Panicz