On Sunday, 8 September 2024 at 22:01:10 UTC, WraithGlade wrote:
Specifically, I want a way to create a print command that
behaves like `@show` from Julia lang or `dump` from (if my
memory is correct) Nim.
Yes.
https://github.com/baryluk/echo/blob/master/echo.d#L205-L209
```d
mixin(echo("echo test: i=$i j=$j Escaping: \\$j, Complicated
i+j=${i+j}, End of tests."));
```
There are other ways of doing similar (using mixing templates for
example), but the machinery would be very similar.
This code is about 13 years old, but still works. (It is
functional and works, but I never it used more than what is in
this repo).
But now that we have interpolation sequences in the language, it
would be way easier, cleaner and more powerful to use them.
I have my custom Linux IO library, that utilizes this, and you
can do thing like this:
```d
Println(i"Ala ma $(ShortHex(123+foo*bar)) $(&m3) $(y.ptr) maybe");
```
(with zero memory allocations or excessive memory copies).