Subject: bug#30237: Generalizing ‘and=>’

From: Mark H Weaver <[email-masked]>
Date: Tue, 30 Jan 2018 23:31:52 -0500

Mathieu Lirzin <[email-masked]> writes:

> IMO It would be nice if multiple values
> were handled too.  here is one solution inspired by ‘compose’.
>
> (define and=>
>   (case-lambda
>     ((val proc) (and val (proc val)))
>     ((val proc . procs)
>      (let loop ((p proc) (ps procs))
>        (if (null? ps)
> 	   (p val)
> 	   (loop (lambda args
> 		   (call-with-values (lambda () (apply p args))
> 		     (lambda (arg0 . args*)
> 		       (and arg0 (apply (car ps) arg0 args*)))))
> 		 (cdr ps)))))))

This generalization will inevitably slow it down, and it's not clear
that this is useful in practice.  It's also not particularly natural,
because these return value(s) somehow need to be interpreted as a
boolean.  There are multiple ways to do that, and it's not clear which
is the best way.

I think we should resist the temptation to make simple things more
complicated without good reason.  Making things more complicated always
has a cost.  I'm a big believer in keeping things simple, especially the
widely used primitive operations.

Thoughts?

      Mark