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
-
-
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 -
Replying to @pcwalton @laurentbercot and
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.
1 reply 0 retweets 1 like -
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
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.
-
-
Replying to @pcwalton @laurentbercot and
I'd be in favor of deprecating it, but regardless of whether it's deprecated it shouldn't be being taught in language tutorials. So much of wrong C usage comes from wrong C tutorials/books/classes. Rust should not copy that.
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
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.