[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] multiple values, and, or, when, unless

On Sun, Jan 6, 2013 at 8:13 PM, Jussi Piitulainen <jpiitula@x> 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).
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.


Scheme-reports mailing list