Implement with-out-str#794
Conversation
|
Hmmm, ostreams are notoriously slow. That's why we don't use them for printing/formatting right now. I would prefer to explore different options which instead redirect stdout/stderr at a lower level. I'm not sure yet exactly how that look, but C folks are able to do this, so it must be possible. |
|
Ohh, I didn't know |
No, |
|
Do we need that generic of a solution? I feel like since % clj
Clojure 1.12.2
user=> (with-out-str (.println System/out "foo"))
foo
"" |
Ok, I chewed on this for a bit. I think we have two options here, depending on how robust we want things to be. Option 1: If we only want to support Option 2: To support whole-program capturing and also the ability to specify custom "writers", we can have |
|
If we do option 1, it'll be a stop-gap solution until we do option 2. I'm ok with this, if it unblocks you, but I think it's important that jank has a Clojure-idiomatic way to redirect to files and such. This is the way. |
|
I like the idea of storing
|
|
The current solution works for my Linux machine, and I assume it will also work for OSX, but Windows will need its own code path. I do wonder if it's time to implement |
|
Hi, just catching up on the conversation. I got this working on windows using Performance wise though, Regarding Option 2 (dup2), I have some concerns about it for
I think @djblue's suggestion of introducing a Thanks |
|
Thanks for the helpful follow up, @ikappaki. I've followed up on the LLVM side, to ping Lang, but until that pans out, are you open to making the CppInterop change? |
Hi @jeaye, I've opened jank-lang/CppInterOp#4 for the interop change. |
|
The change has been merged to main with #810, what is the next step for this PR please? Happy to help with the windows side of things. |
|
@ikappaki if you can tackle the windows side, that would be awesome! |
|
Hi gyus, Sorry for the delay. I've added MS Windows support using tmpfile in djblue#2. As discussed, this is a stopgap solution to get @djblue unblocked. The win implementation is inefficient because it relies on disk I/O, and neither the win nor POSIX implementations currently perform any error handling. I'm looking forward to a proper writer based implementation in the near future. I'd be happy to help with that once @jeaye confirms the design. thanks |
|
|
|
Ok, I think this PR is ready for a final review pass 👍 |
This PR is a POC to support the following forms:
Is this approach what we want for jank?