Replies: 1 comment 2 replies
-
|
I'm not sure I agree this is 'wrong'. If you write (loop [i :in [1 2 3 4]
:while (< i 3)
:before (printf "before i: %p" i)
j :in [100 200 400]
:while (not= (* i j) 600)]
(printf "i: %p j: %p *: %p" i j (* i j)))the output is So the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Using
(break)within a loop with multiple bindings gives surprising (to me) behavior. The documentation for(break)as a special form does specify that it only breaks from the innermost while loop. And a loop with multiple nesting expands into nested while expressions.So to break out of the whole loop the usage of
(prompt :label ... (loop [...] (return :label res) ...))or something similar is needed.For writing user code this requires some attention, but it is not insurmountable. But I believe for some Janet API code that uses
(break)within aloopwith multiple bindings it is wrong:The
:modifier:whileexpands to use(break)within nested while expressions causing the following behavior:Would it be an option to add
(breakloop)or something similar for fixing the:whilemodifier and to make it available as "easier"/"lower cost" option to break out of a loop with multiple bindings?Beta Was this translation helpful? Give feedback.
All reactions