>From what I gather, nimscript offers only `echo`, which is a magic proc, 
>relying on compiler to output messages. In `compiler/vmgen.nim` you can see 
>the AST symbol `mEcho`, corresponding to an `echo` call, performs an `opcEcho` 
>instruction (from `compiler/vm.nim`), which boils down to calling `msgWriteln` 
>from `compiler/msgs.nim` with `{msgStdout, msgNoUnitSep}` args. This proc, as 
>you'd expect, hardcodes adding a line.

  * `mEcho`: 
<https://github.com/nim-lang/Nim/blob/devel/compiler/vmgen.nim#L1253>
  * `opcEcho`: 
<https://github.com/nim-lang/Nim/blob/devel/compiler/vm.nim#L1327>
  * `msgWriteln`: 
<https://github.com/nim-lang/Nim/blob/devel/compiler/msgs.nim#L317>



So, to add a `stdout.write` analogue to nimscript you need to:

  1. Open an issue and a corresponding PR.
  2. Modify `msgWrite` in `compiler/msgs.nim` to take `flags: MsgFlags = {}` so 
you can force it to output to stdout with `msgStdout`.
  3. Introduce some symbol to the AST in `vmgen.nim` and a corresponding 
operation to `vm.nim` to output to stdout without a new line.
  4. Perhaps, change how `mEcho`/`opcEcho` work so they now rely on a newly 
introduced logic and just add a newline symbol to the output in the end.
  5. Convince maintainers to accept your PR.


Reply via email to