3 ms·
You're not supposed to use the stdlib for baremetal programming. > instead of trying to create something new monadic error handling isn't new. It's an old fea
by Manishearth 11y ago
You're not supposed to use the stdlib for baremetal programming.
> instead of trying to create something new
monadic error handling isn't new. It's an old feature used by many languages, and preferred by many over exceptions.
- quotemstr 11y ago> You're not supposed to use the stdlib for baremetal programming. I don't think it's useful to partition the world into microcontrollers and "LOL, memory is finite?" domains. Allocations can fail for normal programs, particularly when imposing subsystem-specific allocation limits or when running in small, crowded address spaces (e.g., mobile devices). It's often useful to be able to recover from this condition without completely killing the process, since process death is much more annoying for users than a specific task failing. (Wouldn't you rather see a video not play than see your entire program die?)
- kibwen 11y agoRust's libcore wasn't split out for "LOL, memory is finite" domains. It exists so that you can write Rust programs that restrict themselves to doing no dynamic allocation whatsoever, as needed for environments where an allocator simply isn't available or allowed.
- quotemstr 11y agoMy point is that I want to write programs that do use dynamic allocation, but also handle failure of this dynamic allocation in a reasonable way. Right now, Rust's philosophy is that you can choose whether to use dynamic allocation, but if you do, it'd better be an infallible allocator.