Hi,
I was wondering how I could persuade a function to return zero
values. From CLtL2 I understood that the function call (values)
was the appropriate way but it doesn't solve my problem.
what I want to do is the following
> (setq *var1* nil
*var2* 'var2)
VAR2
> (list (if *var1*
*var1*
(values))
(if *var2*
*var2*
(values)))
(VAR2)
however my lisp (LCL4.0) returns (NIL VAR2) in stead
of (VAR2) when I evaluate the forms above. What am I
doing wrong????
--
--------------------------------------------------------------
Gertjan van Heijst ·······@swi.psy.uva.nl
Social Science Informatics
Department of Psychology
Date: Thu, 17 Sep 1992 10:36 EDT
From: Gertjan van Heijst <·······@swi.psy.uva.nl>
Hi,
I was wondering how I could persuade a function to return zero
values. From CLtL2 I understood that the function call (values)
was the appropriate way but it doesn't solve my problem.
what I want to do is the following
> (setq *var1* nil
*var2* 'var2)
VAR2
> (list (if *var1*
*var1*
(values))
(if *var2*
*var2*
(values)))
(VAR2)
`(,@(and *var1* (list *var1*))
,@(and *var2* (list *var2*)))
or
(multiple-value-call #'list
(if *var1* *var1* (values))
(if *var2* *var2* (values)))
however my lisp (LCL4.0) returns (NIL VAR2) instead
of (VAR2) when I evaluate the forms above. What am I
doing wrong????
--
--------------------------------------------------------------
Gertjan van Heijst ·······@swi.psy.uva.nl
Social Science Informatics
Department of Psychology
In article <······················@swi.psy.uva.nl>, ·······@swi.psy.uva.nl (Gertjan van Heijst) writes:
|> Hi,
|>
|> I was wondering how I could persuade a function to return zero
|> values. From CLtL2 I understood that the function call (values)
|> was the appropriate way but it doesn't solve my problem.
|> [ example showing how use of (VALUES) actually returns NIL ]
Scott McKay has already posted some code to work around your problem, but this
excerpt from CLtL2 may shed some light on why VALUES behaves so: "In an ordinary
function call, each argument form produces exactly *one* argument; if such a form
returns zero values, NIL is used for the argument..." (page 186).
I suppose one example of an extra-ordinary function call would be a form typed to
the Lisp top-level (aka listener) since (VALUES) actually returns zero values
there.
..................................................
Len Charest, Jr.
JPL Artificial Intelligence Group
·······@aig.jpl.nasa.gov