Jess Version 7.0p1 12/21/2006
Using return to break a (for) or (foreach) is documented behaviour. (It
isn't for (while), but perhaps this is just an omission in the
documentation.)
However:
;; Using return to exit from a loop confuses Jess.
;; Loops won't work any more. A (clear) appears to remove the fault.
;; for + return
(for (bind ?i 0) (< ?i 5) (++ ?i)
(if (= ?i 3)
then (return huhu))
(printout t "i=" ?i crlf ) )
;; foreach + return
(foreach ?el (create$ 1 5 10 50 100)
(if (= ?el 10)
then (return huhu))
(printout t "el=" ?el crlf ))
;; while + return
(bind ?i 0)
(while (<= ?i 3)
do
(if (= ?i 2) then (return huhu))
(printout t "i=" ?i crlf )
(++ ?i) )
;; for instance:
Jess> (for (bind ?i 0) (< ?i 5) (++ ?i) (if (= ?i 3) then (return
huhu)) (printout t "i=" ?i crlf ) )
i=0
i=1
i=2
huhu
Jess> (for (bind ?i 0) (< ?i 5) (++ ?i) (if (= ?i 3) then (return
huhu)) (printout t "i=" ?i crlf ) )
huhu
Jess>
(clear)
Jess> (foreach ?el (create$ 1 5 10 100) (if (= ?el 10) then (return
huhu)) (printout t "el=" ?el crlf ) )
el=1
el=5
huhu
Jess> (foreach ?el (create$ 1 5 10 100) (if (= ?el 10) then (return
huhu)) (printout t "el=" ?el crlf ) )
huhu
Jess>
(clear)
Jess> (bind ?i 0)
0
Jess> (while (<= ?i 3) do (if (= ?i 2) then (return huhu)) (printout t
"i=" ?i crlf ) (++ ?i) )
i=0
i=1
huhu
Jess> (bind ?i 0)
0
Jess> (while (<= ?i 3) do (if (= ?i 2) then (return huhu)) (printout t
"i=" ?i crlf ) (++ ?i) )
huhu
Jess>
Kind regards
Wolfgang
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------