Functional Programming with D

anonymous anonymous at
Sun Apr 14 07:18:37 PDT 2013

On Sunday, 14 April 2013 at 06:35:53 UTC, qznc wrote:
> Sat, 13 Apr 2013 17:38:24 -0700: Ali Çehreli wrote
>> When it is a reference though, not immutable but D's const is 
>> similar to
>> C's const. Otherwise, there is the following difference:
>>      // in C: I have no idea whether c is immutable void 
>> foo(const int *
>>      c);
>>      // in D: I know d is immutable void foo(immutable const 
>> ref d);
>> (Actually, not only I "know", but I "demand" that d is 
>> immutable.)
> The C variant is an mutable pointer to an immutable int. What 
> is not to
> know about that?

You can pass a pointer to a mutable int to the C version foo.
You can't do that with D's immutable.

More information about the Digitalmars-d-announce mailing list