From: Pascal J. B. <pj...@in...> - 2012-04-27 18:12:15
|
"Yves S. Garret" <you...@gm...> writes: > Hi, just curious. I ran the little hello world function that you've described with and without the > (values)) at the end. Without, I got a NIL returned. With the (values)), I did not have that NIL > returned. I would like to know why this is happening? > > I'm guessing that all functions in Lisp return something, even if it's a null (you have "void" in C/ > C++ and Java). So, without the (values)), the function by default returns the null. However, with > the (values)), we are returning that variable, which is not bound to anything, which is just a blank > if it's not bound to nothing. Am I correct? If not, please feel free to explain. There's no variable named values. There's a function named values, which returns a variable number of values: one of each argument. Therefore (values) returns no value, since it has no argument. A function doesn't return nil by default, it returns whatever its returning form returns. In this case if you remove the call to VALUES, it's FORMAT which returns only one value, nil, which are taken by the implicit PROGN which returns them, which are taken by the BLOCK <function-name> which returns them, which are taken by the LAMBDA implicit PROGN which returns them. -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}. |