[ Sorry for double-post Ala'a, I forgot to reply-all :( ]

WITH-NESTING reduces the nesting cost of an arbitrary number of
consecutive binding forms to one level, with a highly regular and
simple syntax almost inherently readable to anyone without prior
exposure (I think?). It may not be the most concise syntax of all, but
it has the benefit of simplicity and most importantly, sanity.

The only reason I'm not actually using it is that I don't often
encounter scenarios complex enough where using it would significantly
improve the situation (and I'd consider it bad style to use it if it
doesn't significantly improve the situation. Usually a simple
refactoring will obviate the "need" for it). As circumstantial
evidence, I had to make a synthetic example to show it in a scenario
where it would help...

(with-nesting ()
 (let ((a 'a)))
 (destructuring-bind (b c) '(b c))
 (multiple-value-bind (d e) (values 'd 'e))
 (let* ((f 'f)
        (g (list f 'g))))
 (destructuring-bind (h i j) (cons f g))
 (progn 'HUGE-body
        (values a b c d e f g h i j)))
=> A, B, C, D, E, F, (F G), F, F, G

VS

(let ((a 'a))
 (destructuring-bind (b c) '(b c)
   (multiple-value-bind (d e) (values 'd 'e)
     (let* ((f 'f)
            (g (list f 'g)))
       (destructuring-bind (h i j) (cons f g)
         (progn 'HUGE-body
                (values a b c d e f g h i j)))))))

_______________________________________________
pro mailing list
pro@common-lisp.net
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro

Reply via email to