unless bug?

Q&A's, tips, howto's
Post Reply
psilwen
Posts: 21
Joined: Thu Jul 03, 2014 5:25 am

unless bug?

Post 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
(reverse "newlisp")

Lutz
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: unless bug?

Post 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.

Post Reply