Re:Why Rust ditched pure functions
by kibwen on Friday December 20, 2013 @09:27AM
(#6941507)
D and Rust are vastly different beasts. Here's why none of the arguments from that page apply to Rust:
In Rust, immutability is the default, and you must always opt in to mutability. A function's type signature will always make it apparent as to which arguments are mutable and which are not. If you declare a variable as mutable but then never mutate it, the compiler will pester you to make it immutable. Furthermore, Rust is so hell-bent against global mutable state that even reading global state that is declared as mutable requires one to wrap the code in an `unsafe {}` block.
Rust does not have exceptions, and prefers to use returned algebraic datatypes and non-unwinding conditions to handle errors.
As alluded to earlier, all functions in Rust are safe by default. An explicit `unsafe {}` block is required to do stuff like inline assembly and type transmutation, and functions themselves can be marked as `unsafe` in order to force callers to use an unsafe block when calling them.
[ Parent
| on HN ]
There are no comments on this comment yet.