"retard" <r...@tard.com.invalid> wrote in message news:hn1717$24t...@digitalmars.com... > > Having functional core constructs often helps in writing immutable > functional code. Instead of first declaring a mutable variable and then > assigning it a value later, with functional constructs you can > immediately assign the result without requiring a mutable temporary > state, e.g. > > int a = null; > > switch(b) { > case foo: a = something; > ... > default: a = something_else; > } > > vs > > const immutable int a = switch(b) { > case foo: something; > ... > default: something_else; > } > > The problem with mutability here is that after the assignment the mutable > state doesn't automatically change. >
That would also fit in very nicely with non-nullables and/or a system where it's an error to read a var before it's statically known to have be written to (instead of default init values).