Why is immutable not possible as a result of a reduce expression?

Jonathan M Davis jmdavisProg at gmx.com
Sat Jan 5 16:59:38 PST 2013


On Saturday, January 05, 2013 16:18:51 Ali Çehreli wrote:
> On 01/05/2013 12:09 PM, Simen Kjaeraas wrote:
>  > A little details is that immutable auto is unnecessary, as immutable
>  > implies auto (the details are more complex, but that's the short
> 
> version).
> 
> It is true that the OP does not need auto when there is already
> immutable but does immutable really imply auto, or are they orthogonal?
> 
> Ali
> 
> P.S. I had wrongly assumed that D's auto was the same as C++11's auto
> and that it came from "automatic type deduction." That is not true in D.
> As in C and old C++, D's auto comes from "automatic storage duration."
> We still use it for automatic type deduction to make the syntax happy
> when there is no other keyword to put to the left of the symbol.

D's auto _is_ automatic type deduction like in C++11. It's just that const, 
immutable, and enum also deduce the type if you don't give it (with the 
addition of making the type const or immutable in the cases of const and 
immutable).

auto a = 1;
const c = 1;
immutable i = 1;
enum e = 1;

all do type inferrence and all work just fine.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list