News for hackers. Stuff that matters.
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:

  > Pure means your function does not use or change mutable 
  > global state except what is available from the 
  > arguments. If in addition the arguments are not 
  > mutable, a function is called “strongly pure”.
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.

  > Nothrow means your function will never throw an 
  > exception.
Rust does not have exceptions, and prefers to use returned algebraic datatypes and non-unwinding conditions to handle errors.

  > Safe means your function cannot break the type system 
  > via unsafe casts or inline assembly.
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.

There are no comments on this comment yet.