GNU bug report logs - #30237
Generalizing ‘and=>’

Previous Next

Package: guile;

Reported by: Mathieu Lirzin <mthl <at> gnu.org>

Date: Wed, 24 Jan 2018 12:11:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Mark H Weaver <mhw <at> netris.org>
To: Mathieu Lirzin <mthl <at> gnu.org>
Cc: 30237 <at> debbugs.gnu.org
Subject: bug#30237: Generalizing ‘and=>’
Date: Tue, 30 Jan 2018 23:31:52 -0500
Mathieu Lirzin <mthl <at> gnu.org> 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




This bug report was last modified 4 years and 26 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.