[plt-scheme] minor WHEN and UNLESS question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Jul 6 08:34:13 EDT 2008

At Sat, 5 Jul 2008 21:47:52 -0400, Eli Barzilay wrote:
> Looks to me like something that perhaps was planned?

Possibly; I forget.

Breaking tail position would be a bad idea, in any case, so let's call
this a doc bug. The last expression in a `when' or `unless' form is in
tail position, and it will stay that way.

Matthew


> I think that the main point of the documentation should be that *you*
> shouldn't use the result of `when'/`unless', because it might be void
> (not #f, btw).  If the forms need to always return void, then the
> implementation will not have the subform in a tail-position, which
> will destroy things like
> 
>   (let loop ()
>     ...
>     (unless blah (loop)))
> 
> but the description says just that ("No expr is in tail position with
> respect to the when form").
> 
> 
> On Jul  5, Matthias Felleisen wrote:
> > 
> > Like all Scheme conditionals, when/unless return the value of their
> > sub-expressions if the condition is true. Otherwise, they produce
> > false. The docs are wrong.
> > 
> > Thanks for reporting the problem. For future discoveries of
> > mistakes, please use Help Desk to report them. -- Matthias
> > 
> > 
> > 
> > On Jul 5, 2008, at 4:19 PM, Yavuz Arkun wrote:
> > 
> > > This is a rather minor issue I noticed in the documentation:
> > >
> > > According to http://docs.plt-scheme.org/reference/when_unless.html,
> > > the results of evaluating WHEN and UNLESS are ignored. According to
> > > http://docs.plt-scheme.org/reference/when_unless.html, the result is
> > > #<void> (which is of course ignored by the REPL). Evaluating the
> > > following expression in module language
> > > shows that actually the result of the last expression in the body is
> > > available at least in some cases; didn't test extensively.
> > >
> > >> (+ 1 (when #t (+ 1 2) (+ 3 4)))
> > > 8
> > >
> > >> (+ 1 (unless #f (+ 1 2) (+ 3 4)))
> > > 8
> > >
> > > So the question is...which version is the correct one? Ignored,
> > > #<void>, value of the last expression in the body?
> > > --Yavuz
> > > _________________________________________________
> > >   For list-related administrative tasks:
> > >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > 
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> -- 
>           ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                   http://www.barzilay.org/                 Maze is Life!
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.