maybe-ref and either-ref: default value of failure Shiro Kawai (04 Jun 2020 04:47 UTC)
Re: maybe-ref and either-ref: default value of failure Shiro Kawai (04 Jun 2020 05:00 UTC)
Re: maybe-ref and either-ref: default value of failure Marc Nieper-Wißkirchen (04 Jun 2020 07:40 UTC)
Re: maybe-ref and either-ref: default value of failure Marc Nieper-Wißkirchen (04 Jun 2020 09:14 UTC)

Re: maybe-ref and either-ref: default value of failure Marc Nieper-Wißkirchen 04 Jun 2020 09:14 UTC

I just noticed that you also asked about `maybe-ref' and not only
about `either-ref'. I agree that `raise' as a default argument doesn't
make sense here. I would propose that the default procedure is
implementation-specific and SHOULD raise an error.

Am Do., 4. Juni 2020 um 09:40 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@nieper-wisskirchen.de>:
>
> Am Do., 4. Juni 2020 um 07:00 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
> >
> > Correction - failure of either-ref does take arguments.    But 'raise' only works if Left has only one argument (and although you usually store some kind of mssage there, it doesn't look very useful to raise that message alone---but that's a different story.)
>
> I think that the behavior specified in Draft #5 is the correct one.
> `raise' usually takes some kind of error object (e.g. one that is
> raised by the `error' procedure), whose payload can be a message and a
> list of irritants. If the Either monad is used for this purpose
> (regular values on the right-hand side vs an error condition on the
> left-hand side), you would store the error object to be eventually
> raised (or otherwise handled) in the left-hand side.
>
> But the Either monad is more general than this.  In some use cases, it
> makes sense to view the right and left cases symmetrically. In that
> case, the default `failure' argument may not be helpful but that's no
> problem because you can always provide your own one.
>
> Furthermore, from the evaluation model of Scheme, `raise' could easily
> take multiple values (as raising an error can be viewed of exiting a
> procedure through a special continuation). I don't know a Scheme yet
> that implements it this way, but it is certainly possible (and there
> is a point in saying that this would make Scheme even more regular).
> So, in case some Scheme extends the domain of `raise' in this way,
> `maybe-ref' with its default argument will automatically do the right
> thing.