Re: Maybe macros Wolfgang Corcoran-Mathe 28 Jun 2020 18:51 UTC

On 2020-06-28 19:43 +0200, Marc Nieper-Wißkirchen wrote:
> If the values of the Maybe/Either returned by the empty `...-and' or
> `...-or' forms are accessed to be processed further, the code is most
> likely doing something very wrong. Zero values actually help here to
> catch such logical errors because they will more likely raise an
> error.
>
> [snip]
>
> If you want to leave the payload unspecified, you should also leave
> the number of unspecified values unspecified. That certainly makes
> sense.

Agreed that the code is certainly doing something wrong.  However,
the protocol of returning no values in case no meaningful value can be
returned doesn't seem to be used much in Scheme, as yet.  But we might
want to allow that to be an option, so I agree--leaving the payload
completely unspecified is probably the right thing here.

> The best unit would be a Just/Left/Right for which it would be an
> error to unwrap it. This could be some singleton value.

I like this, although I suspect that few implementations would bother
to signal this error; it would be necessary, I think, to add special
"forbidden" Justs/Lefts/Rights for this purpose, and to check for them
when unwrapping containers.  That seems a bit messy.

--
Wolfgang Corcoran-Mathe  <xxxxxx@sigwinch.xyz>

"I have discovered a truly marvelous implementation of this
function which this 80-column limit is too narrow to contain."
--fishythefish