Why is the "in" storage class missing from the ParameterStorageClass enum?
Andrej Mitrovic
none at none.none
Thu Jan 20 19:03:09 PST 2011
import std.stdio;
import std.traits;
alias ParameterStorageClassTuple STCTuple;
alias ParameterStorageClass STC;
void foo(in int[] x) { /*x[0] = 5; // This would be a compile-time error*/ }
void bar(int[] x) { x[0] = 5; }
void main()
{
assert(STCTuple!foo[0] == STC.NONE);
assert(STCTuple!bar[0] == STC.NONE);
}
Someone said that "in" was the default storage class when there is no storage class specified for a parameter. But if that is true then how come bar can modify the contents of the x parameter? If parameters really have "in" as the default storage class, bar's function body would be a compile time error, just like foo's is if you uncomment its code. (Yes, I know a fat pointer is passed in with both functions. But "in" is supposed to give some guarantees as to what you can do with a parameter.)
So, which part of this am I misunderstanding here?
More information about the Digitalmars-d
mailing list