From: Tim Bradshaw
Subject: RETURN / RETURN-FROM and values
Date: 
Message-ID: <ey3hetoss7g.fsf@cley.com>
I keep finding myself typing things like this:

        (return-from foo x nil t)

when I mean

        (return-from foo (values x nil t))

Can anyone think of a good reason why RETURN and RETURN-FROM should
not be defined that way?

I can think of one good reason which is that it's not compatible with
what they do now -- (return-from foo) returns a single value of NIL
and not no values, but other than the small issue of breaking lots of
code, are there any others?

Thanks

--tim

From: Kent M Pitman
Subject: Re: RETURN / RETURN-FROM and values
Date: 
Message-ID: <sfwu1xoofdg.fsf@world.std.com>
Tim Bradshaw <···@cley.com> writes:

> I keep finding myself typing things like this:
> 
>         (return-from foo x nil t)
> 
> when I mean
> 
>         (return-from foo (values x nil t))
> 
> Can anyone think of a good reason why RETURN and RETURN-FROM should
> not be defined that way?

Yes.  Because it's not as compatible as it probably looks.
 
Consider (defun foo () (values 1 2)) and the following set of examples:

 (return-from foo 1)        ; #1: CL defines this to return 1 value
 (return-from foo 1 2)      ; #2: CL doesn't define this, but you want to
 (return-from foo (foo) 3)  ; #3: You want this to return 1, 3 I'm betting
 (return-from foo (foo))    ; #4: CL defines this returns 1, 2

The only way to make RETURN-FROM work compatibly with what you want is
to make it pick up arguments like MULTIPLE-VALUE-CALL, but I find that
to be a remarkably unintuitive merge to be used only very, very carefully.
That would change example #3 above to return 1,2,3, which would give all
four examples consistent behavior, but I think would often not be what
people want.  Also, just guessing, I bet it's tricky and computationally
expensive to set up that kind of return-value accumulation.

> I can think of one good reason which is that it's not compatible with
> what they do now -- (return-from foo) returns a single value of NIL
> and not no values, but other than the small issue of breaking lots of
> code, are there any others?

This is also so, but is "in the noise" compared to the above problems.
From: Kalle Olavi Niemitalo
Subject: Re: RETURN / RETURN-FROM and values
Date: 
Message-ID: <iznk7yklo88.fsf@stekt34.oulu.fi>
Tim Bradshaw <···@cley.com> writes:

> Can anyone think of a good reason why RETURN and RETURN-FROM should
> not be defined that way?

What would be your syntax for (cl:return-from foo (values-list bar))?
It can't be (apply #'tfb:return-from foo bar).
From: Tim Bradshaw
Subject: Re: RETURN / RETURN-FROM and values
Date: 
Message-ID: <ey3d74cso3l.fsf@cley.com>
* Kalle Olavi Niemitalo wrote:
> What would be your syntax for (cl:return-from foo (values-list bar))?
> It can't be (apply #'tfb:return-from foo bar).

Right.  That's the example I was looking for that shoots the whole
thing down in flames, thank you!

In fact even better is (return-from x
(function-returning-multiple-values)) which in my system would return
just one value, but in CL returns all of them.

--tim