Is D a cult?

retard re at tard.com.invalid
Tue Mar 9 12:49:15 PST 2010


Tue, 09 Mar 2010 13:58:45 -0500, Nick Sabalausky wrote:

> "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

Of course, a nullable type is just a simple sum type and pattern matching 
works perfectly with algebraic types.

> 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).

They're better known as dataflow variables.



More information about the Digitalmars-d mailing list