Is D a cult?

Nick Sabalausky a at a.a
Tue Mar 9 10:58:45 PST 2010


"retard" <re at tard.com.invalid> wrote in message 
news:hn1717$24to$1 at 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).





More information about the Digitalmars-d mailing list