Write error is a very normal condition you have to expect, however it's reported, though. And if you're implementing std utilities you need to translate it into the specified effect on exit status to match expectations of invoking programs/scripts...
-
-
Replying to @RichFelker @whitequark
So it sounds like these tool replacements written in Rust are just sloppily written.
1 reply 0 retweets 2 likes -
Replying to @RichFelker
sort of, but the issue goes deeper: the standard library makes it extra hard to actually react to the write error because of the way println!() is designed, arguably a design mistake
1 reply 0 retweets 2 likes -
Replying to @whitequark @RichFelker
I really don't get why basic stuff in the stdlib panics on failures. You have an error handling facility, people. Use it.
1 reply 0 retweets 1 like -
Replying to @pikhq @whitequark
It actually panics rather than throwing or returning an error?!
2 replies 0 retweets 0 likes -
Replying to @RichFelker @whitequark
Yep. You have to use different functions instead to actually catch errors on writes to stdout.
2 replies 0 retweets 1 like -
Essentially, in Rust you should mistrust any function that does some syscall and doesn't return Result IMO
1 reply 2 retweets 5 likes -
Replying to @pikhq @whitequark
BTW I don't mean to dunk on Rust here. Rather I want to draw out and understand pitfalls in case I end up using it in future, and to encourage others to be aware of them.
1 reply 0 retweets 2 likes -
Sounds like a good opportunity to dunk on the Rust stdlib though. Making a language that's supposed to be safe, and not handling write errors in very standard functions in the stdlib sounds like a major misdesign, a newbie mistake that shows terrible lack of experience with Unix.
2 replies 0 retweets 0 likes -
Replying to @laurentbercot @RichFelker and
It checks errors and panics. This was a design decision to minimize the amount of noise for common cases. println! is a convenience macro. println!(“foo”) is shorthand for: writeln!(std::io::stdout(), “foo”).unwrap()
1 reply 0 retweets 0 likes
It was *always* intended that print/println is a convenience macro, and write/writeln is the one you use for proper error handling. Maybe that was not made clear enough, but that was the design.
-
-
Replying to @pcwalton @laurentbercot and
In that case the tutorials/hello worlds should be teaching write/writeln and pretending println doesn't exist...
1 reply 0 retweets 0 likes -
Replying to @RichFelker @laurentbercot and
Everyone agreed that either (a) having println drop errors on the floor or (b) panic is not great either way. Panic was chosen because it seemed like a good conservative default. Maybe println should be deprecated. I wouldn’t object to deprecating it.
1 reply 0 retweets 3 likes - 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.