From: Kostruba
Subject: Lisp question
Date: 
Message-ID: <4656@ucsbcsl.ucsb.edu>
I have a construct like:

(defun f ()
    (prog (task ident)
           .
           .
           .
       (setq task ...)
       (setq ident ...)
       (values task ident)
    )
)

Is the values statement returning values from the prog or the function?
If it's returning from the prog, how can I return these variables from the
function without making them global?

Thanks

::::::::::::::::::::::::::::::::::::::::::::::
····@cs.ucsb.edu
::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::::::::
····@cs.ucsb.edu
::::::::::::::::::::::::::::::::::::::::::::::

From: Len Charest
Subject: prog returns NIL (was Re: Lisp question
Date: 
Message-ID: <1992May15.002137.3050@jpl-devvax.jpl.nasa.gov>
In article <····@ucsbcsl.ucsb.edu>, ····@ucsb.edu (Kostruba) writes: 
|> (defun f ()
|>     (prog (task ident)
|>            .
|>            .
|>            .
|>        (setq task ...)
|>        (setq ident ...)
|>        (values task ident)
|>     )
|> )
|> 
|> Is the values statement returning values from the prog or the function?

The PROG form returns NIL by definition if the end of its body is reached. (PROG is simply a macro equivalent to nested BLOCK/LET/TAGBODY forms.) If you want to return the values of IDENT and TASK as the result of function F then wrap a RETURN around the VALUES form like so

	(return (values task ident))

IMHO, you should stay away from PROG. Its outdated and confusing. In this case a LET statement would have been clearer.

PS A more descriptive message subject would've been cool, too.
..................................................
                                  Len Charest, Jr.
                 JPL Artificial Intelligence Group
                          ·······@aig.jpl.nasa.gov
From: Douglas Rand
Subject: Re: Lisp question
Date: 
Message-ID: <1992May15.141650.21744@osf.org>
In article <····@ucsbcsl.ucsb.edu>, ····@ucsb.edu (Kostruba) writes:
|> I have a construct like:
|> 
|> (defun f ()
|>     (prog (task ident)
|>            .
|>            .
|>            .
|>        (setq task ...)
|>        (setq ident ...)
|>        (values task ident)
|>     )
|> )
|> 
|> Is the values statement returning values from the prog or the function?
|> If it's returning from the prog, how can I return these variables from the
|> function without making them global?
|> 

The answer is yes.  Seriously,  the values returns a set of two values from
the prog and that becomes the two values returned from the function since the 
values returned from the prog are the last values returned from a form in 
the function and thus become the function's returned values (a function's
forms are evaluated as in a progn where the last value becomes the return
value).

I'm presuming that prog does not explicitly disallow this,  it shouldn't since
it is like most of the other block forms.  Why not try this and see the result?
Then let us know.

-- 
Douglas S. Rand <·····@osf.org>
Snail:	11 Cambridge Center,  Cambridge,  MA  02142
Disclaimer: I don't know if OSF agrees with me... let's vote on it.
Amateur Radio: KC1KJ