One way I like to try out new languages is to get my hello world app to throw errors. The easiest way to do that (on Linux) is to redirect console output to a device that has no free space:
At this point I usually begin to figure out how to handle the I/O error and return a nonzero exit code. Unfortunately println() has a console effect rather than an io effect, so it doesn't look like there's a good way to handle this error. I don't see any other interfaces to write to stdout either.
Some questions:
If I wanted to do this today without any changes to std/core, what would be the recommended approach? Create my own extern print function in C that reports errors?
Would it make sense to modify the console effect so it can report errors?
Or would it make more sense to introduce a different mechanism that gives lower-level access to the standard I/O streams?
One way I like to try out new languages is to get my hello world app to throw errors. The easiest way to do that (on Linux) is to redirect console output to a device that has no free space:
(Inspired by Bugs in Hello World)
At this point I usually begin to figure out how to handle the I/O error and return a nonzero exit code. Unfortunately
println()
has aconsole
effect rather than anio
effect, so it doesn't look like there's a good way to handle this error. I don't see any other interfaces to write to stdout either.Some questions:
std/core
, what would be the recommended approach? Create my ownextern
print function in C that reports errors?console
effect so it can report errors?