-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
each
macro improper behavior?
#1400
Comments
Have you tried to flush stdout after |
@pepe Just in case, I did just now try that. There is no difference if one calls |
Thanks. TBH, I just woke up and saw the combination of print and order :-), so my suggestion went. |
FWIW, diff --git a/src/boot/boot.janet b/src/boot/boot.janet
index 46fcabae..e3b5ee9e 100644
--- a/src/boot/boot.janet
+++ b/src/boot/boot.janet
@@ -442,8 +442,8 @@
:each ~(,in ,ds ,k)
:keys k
:pairs ~[,k (,in ,ds ,k)]))
- (set ,k (,next ,ds ,k))
- ,;body))))
+ ,;body
+ (set ,k (,next ,ds ,k))))))
(defn- iterate-template
[binding expr body] |
@sogaiu If that works with |
I haven't really thought much about the details here, but I've submitted #1402 anyway. FWIW, I did run some more tests across some of my repositories and those didn't turn up anything. |
Swap set / body order for each (#1400)
@llmII Perhaps this issue can be closed? |
Fixed in #1402. |
To illustrate the issue:
The expected output, which is yielded by the first
lines-from-buf
is as follows:The second function yields and sets res correctly (looking at the output from
pp
) buteach
never sees the first yielded value seemingly as shown below:I think the macro expands to the incorrect form as illustrated with:
Why is
print line
executed after theset
instead of before? Invokingnext
on a fiber could (and does as shown here) modify what is returned when what is returned is a reference type consumed throughout the entirety of the fiber's lifecycle.I would think putting the user provided form (in this case
(print line)
) before theset
would do better in all cases.The text was updated successfully, but these errors were encountered: