newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Sammo on January 13, 2004, 02:21:11 PM

Title: returning the empty list
Post by: Sammo on January 13, 2004, 02:21:11 PM
shouldn't both return ()?



> (if true '() '())

()



> (if nil '() '())

nil
Title:
Post by: Lutz on January 13, 2004, 05:43:31 PM
'if' can take multiple condition/action pairs similar o 'cond' but wihtout the parenthesis, so it take the last '() as a condition and evaluates it. As it evluates to logigal nil it returns nil.



I agree that this very un-intuitive,  and will change the behaviour for both 'if' and 'cond', so in the future:



(if nil '() '()) => ()    ; previously nil

and



(cond (nil 1) (nil 2) ('())) => () ; previously nil



Lutz