bug-guile
[Top][All Lists]
Advanced

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

bug#30237: Generalizing ‘and=>’


From: Mark H Weaver
Subject: bug#30237: Generalizing ‘and=>’
Date: Tue, 30 Jan 2018 23:31:52 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Mathieu Lirzin <address@hidden> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]