unless bug?

Q&A's, tips, howto's

unless bug?

Postby psilwen » Fri Jun 01, 2018 2:20 pm

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")
psilwen
 
Posts: 21
Joined: Thu Jul 03, 2014 5:25 am

Re: unless bug?

Postby Lutz » Fri Jun 01, 2018 5:29 pm

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.
Lutz
 
Posts: 5254
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron