Re: [Scheme-reports] multiple values, and, or, when, unless Jussi Piitulainen (06 Jan 2013 11:14 UTC)
Re: [Scheme-reports] multiple values, and, or, when, unless Jussi Piitulainen (06 Jan 2013 11:46 UTC)
Re: [Scheme-reports] multiple values, and, or, when, unless Jussi Piitulainen (06 Jan 2013 13:12 UTC)

Re: [Scheme-reports] multiple values, and, or, when, unless Jussi Piitulainen 06 Jan 2013 11:45 UTC

Alex Shinn writes:
> On Sun, Jan 6, 2013 at 8:13 PM, Jussi Piitulainen wrote:
> > Alex Shinn writes:
> > > On Sun, Jan 6, 2013 at 7:15 PM, Andy Wingo wrote:
> > > >
> > > > I used to agree with you, but requiring the consequent to be in
> > > > tail position means that the last expression is evaluated in the
> > > > continuation of the "when" expression as a whole.  I don't think
> > > > you can get around this with a special "this is unspecified"
> > > > exception -- you've already specified it.  Is there any definition
> > > > other than (if TEST (begin CONSEQUENT ...)) that actually fits the
> > > > requirements?
> > >
> > > It's not particularly useful to use when/unless in tail context
> > > anyway, so I think we should just remove these from the list
> > > of tail calls.
> >
> > So (let handlificate-all ((next (get)))
> >       (unless (eof-object? next)
> >          (handlificate next)
> >          (handlificate-all (get))))
> >
> > would be a bad thing to write. Is this consistent with Scheme?
>
> Some would indeed argue it would, since the whole
> loop is dependent on side-effects (but that's the same
> argument against unless in the first place).

That might be reading from some source and writing in some sink, which
are side-effects. The point, though, is that it would not be like
Scheme to have "unless" in the language but not being allowed to rely
on bounded space in the above. Especially when the obvious
implementation of "unless" would provide proper tail recursion.

> > It would be better to remove when and unless altogether. Is there
> > any real downside to treating them as equivalent to (if TEST
> > (begin ...))  and (if (not TEST) (begin ...)), as I think Andy is
> > suggesting.
>
> I just don't want to specify the result of the when.  Whatever
> is wrong with just saying:
>
>   If the test is true, the body is executed in tail position.
>   The result of the `when' is unspecified.
>
> ?  This is true regardless, because if the test is false the
> result is unspecified.  Therefore, to partially specify the
> result you need to say "if the test is true the result is ...,
> otherwise the result is unspecified."  This is clumsy and
> meaningless, and no one would ever want to use the
> result anyway.

I don't care about the result. I care about the tail recursion.
However, adding the "otherwise" seems good to me. I think of "unless"
and "when" as short-hand for (if ... (begin ...)) anyway, and would
like to continue thinking so.

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports