Page 1 of 1

unless bug?

Posted: Fri Jun 01, 2018 2:20 pm
by psilwen
syntax: (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.

Code: Select all

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

Code: Select all

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

Re: unless bug?

Posted: Fri Jun 01, 2018 5:29 pm
by Lutz
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/newlis ... tml#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.