Closed llmII closed 7 months ago
Have you tried to flush stdout after pp
?
@pepe Just in case, I did just now try that. There is no difference if one calls (:flush stdout)
directly after pp
in the second implementation.
Thanks. TBH, I just woke up and saw the combination of print and order :-), so my suggestion went.
FWIW, make test
doesn't show errors for:
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 make test
and works with the second example of lines-from-buf
from the original post in this thread, it'd be awesome if you submitted the PR to get that change.
I haven't really thought much about the details here, but I've submitted https://github.com/janet-lang/janet/pull/1402 anyway.
FWIW, I did run some more tests across some of my repositories and those didn't turn up anything.
@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.