Can someone explain why this is not an error?
Adam Ruppe
destructionator at gmail.com
Thu Jul 1 09:58:54 PDT 2010
I don't think this is really a special case: they are all sharing the
same keywords.
immutable a = 1, b = "a"; // both a and b are immutable
string a = "a", b = "b"; // both a and b are strings
immutable int a = 1, b = 2; // both a and b are immutable ints
I'd say the bug is that the documentation uses the wrong word; it
isn't "the same type" but rather that all must match the... stuff...
on the left, so the comma separated list is identifiers and
initializers, not types and storage classes (I don't know how to word
it best, but it makes perfect sense.)
What it forbids is C's habit of surprising you:
int* a, b; // surprise, b is of type int!
But, there's nothing really surprising in the immutable case. All
variables are indeed immutable (and auto, which is inferred from the
missing type).
More information about the Digitalmars-d
mailing list