File I/O basics (0.16)

Regarding platform eccentrics and pitfalls, a few days ago I implemented an input command for my hobby language, based on takeDelimiterExclusive with \\n, with a little example program that asks for your name and then greets you with your name.

This resulted in strange behaviour, and it took me a while to figure out what’s going on (because I tried emojis at the same time, at first I thought they’d cause it).

The reason was as simple as can be (and well-known to me): The Windows terminal uses CR LF instead of just LF as a line delimiter, and so my input result ended with the CR, causing the exclamation mark that should end the line to overwrite the start of the line.

2 Likes

That could be a good framing. I’m certainly finding that a lot of the existing sources treat these as only for logging or debug output, but that doesn’t help a CLI-tool author.

2 Likes

Yes. Consensus: another article, dedicated. I’m not in a special position to create that at the highest quality, but I might take a stab at it in awhile (couple of weeks) if another hasn’t taken up the mantle.

1 Like

Yeah. I think I kinda asked for this, too, re reading STDIN and writing to STDOUT.

Additionally, I would ask for complete examples, without ellipses, so somebody new to Zig can really understand the complete code and context.

1 Like

Oh my god, i have been searching for this tutorial for a while. Tks man

1 Like