wasm4 icon indicating copy to clipboard operation
wasm4 copied to clipboard

tracef should not emit a newline at the end

Open jacereda opened this issue 2 years ago • 4 comments

There should be some way to emit a string without a newline, and looks like tracef is the answer if it didn't emit the final newline. See https://github.com/aduros/wasm4/pull/611

In Forth it's idiomatic to emit lines like:

: foo ." 1+2=" 1 2 + . cr ;

With the current tracef behaviour it's inconvenient to implement that, since it would require buffering until a cr is performed.

jacereda avatar Feb 21 '23 23:02 jacereda

Yeah, i would prefer to have both versions as one without a newline would facilitate printing various stuff in the same line (in my case, cause I like creating toy Langs, so i would have to implement string buffers first if i would like to print stuff that is more complex). But when i asked why it was this way, @aduros said on discord: "Yeah, the intent was to have a drop in replacement for console.log() for debugging, and not fully expose stdout"

So i guess it is intended to not support this :/

LunaAmora avatar Feb 22 '23 15:02 LunaAmora

Maybe a SYSTEM_FLAG to opt-in as I suggested in https://github.com/aduros/wasm4/pull/611#issuecomment-1440704735

jacereda avatar Feb 22 '23 19:02 jacereda

it is possible tho to use ANSI control codes to print on the line above, move the cursor, clear the terminal... https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797

came pretty handy on debugging real time information to me

Ruulul avatar Nov 20 '23 14:11 Ruulul