Re: Maybe macros Marc Nieper-Wißkirchen 27 Jun 2020 20:46 UTC

Am Sa., 27. Juni 2020 um 20:55 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
>
> Sounds good to me.   So the list of new macros is maybe-and, maybe-or, maybe-and-let* (more verbose but clearer), and their either-* analogues. I'll add these to SRFI 189 when I have a chance.
>
> I don't think we need -each-in-list if we define -and to work that way: it returns the first Nothing/Left if there is one, or the last Just/Right if there isn't.  This is exactly how standard Scheme `and` works.  If there are no arguments, you get a wrapped #t.

There's a difference to the standard `and' because  `each-in-list' is
not a special form and all arguments will be evaluated.

> Of course -or is the dual: it returns the first Just/Right if there is one, and the last Nothing/Left if there isn't.  (There is no need to say "last" in R7RS-small, because there is only one #f).  If there are no arguments, you get Nothing or (I suppose) Left #f.

I have to think of how much `-and' and `-or' without any argument make
sense logically. In any case, the payload of the Just/Right or the
Left would have nothing to do with truth or the falsehood of the
`-and' or `-or' form. So wrapping `#t' or `#f' is definitely not "the
right thing".

Zero values may make sense, so that, say,

`(either-or ...)' becomes equivalent to `(either-or (left) ...)' and
`(either-and ...)' becomes equivalent to `(either-and (right) ...)'.

Marc