wasm4 icon indicating copy to clipboard operation
wasm4 copied to clipboard

Fix #417

Open jacereda opened this issue 2 years ago • 7 comments

This is my attempt to fix tracef for the wasm3 runtime. Looks convoluted, and it is, but it's just that implementing this portably is a PITA.

jacereda avatar Feb 21 '23 22:02 jacereda

Also see #599

JerwuQu avatar Feb 21 '23 22:02 JerwuQu

That one is simpler, but doesn't allow formatting (%08d). Also, it seems to emit a newline at the end, that's bad. tracef should behave like printf. Otherwise there's no way to emit a partial line, and that's quite useful.

jacereda avatar Feb 21 '23 22:02 jacereda

It behaves in both of those ways to be identical to the web runtime.

JerwuQu avatar Feb 21 '23 22:02 JerwuQu

In that case, the web runtime is seriously broken. There must be some way to emit a single character to the console without a newline.

jacereda avatar Feb 21 '23 22:02 jacereda

I personally don't see this is a big issue since you are quite literally able to format the string and shouldn't need multiple calls to it. What is the use-case here that you feel this strongly about?

More technically, web browsers can't print single characters to the log, so you'd have to buffer it. If doing it that way, aside from breaking all current games using tracef, it's arguably also unintuitive to new users when nothing comes out in the console at all if they forget the newline.

JerwuQu avatar Feb 21 '23 23:02 JerwuQu

I personally don't see this is a big issue since you are quite literally able to format the string and shouldn't need multiple calls to it. What is the use-case here that you feel this strongly about?

The use case I feel strongly about this, is that when experimenting with creating toy Langs, it puts some unecessary difficulty/annoyance on debugging stuff, as you would have to implement an string buffer first to have an clearer debug experience. But this is not a common thing to need, so i know it's not that important :p

LunaAmora avatar Feb 22 '23 16:02 LunaAmora

It's important to me because that's exactly my use case, a toy language.

How about having a SYSTEM_STANDARD_TRACING to opt-in for this behaviour in the wasm3 runtime?

jacereda avatar Feb 22 '23 19:02 jacereda