unless bug?

Started by psilwen, June 01, 2018, 07:20:02 AM

Previous topic - Next topic

psilwen

Quotesyntax: (unless exp-condition body)

The statements in body are only evaluated if exp-condition evaluates to nil or the empty list (). The result of the last expression in body is returned or nil or the empty list () if body was not executed.


newLISP v.10.7.3 32-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h
> (unless (file? "hello") (make-dir "hello"))
true
> (unless (file? "hello") (make-dir "hello"))
true
> (unless (file? "hello") (make-dir "hello"))
true


newLISP v.10.7.3 32-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h
> (when (not(file? "hello")) (make-dir "hello"))
true
> (when (not(file? "hello")) (make-dir "hello"))
nil
> (when (not(file? "hello")) (make-dir "hello"))
nil
(reverse \"newlisp\")

Lutz

#1
The documentation was wrong. Should say:



"The statements in body are only evaluated if exp-condition evaluates to nil or the empty list (). The result of the last expression in body is returned or the return value of exp-condition if body was not executed."



Now changed here: http://www.newlisp.org/downloads/newlisp_manual.html#unless">http://www.newlisp.org/downloads/newlis ... tml#unless">http://www.newlisp.org/downloads/newlisp_manual.html#unless



Whith if, when, unless the return value is always based on the last expression evaluated, which is either the body or the conditional expression.