immutable, const, enum

Georg Wrede georg.wrede at iki.fi
Wed Apr 29 03:12:38 PDT 2009


bearophile wrote:
> Paul D. Anderson:
>> From the D2.0/Language/Functions page, under Function Parameters:
>> "The in storage class is equivalent to const scope."
>> That's why the "const in" combination doesn't work.
> 
> Why is this working then, and printing 100?
> 
> import std.stdio: writeln;
> void foo(const ref int x) {
>     writeln(x * 10);
> }

You are not changig x here. The x*10 just multiplies and returns its 
result to writeln.

> void main() {
>     int y = 10;
>     foo(y);
> }
> 
> Note that the following doesn't compile:
> void foo(in ref int x) {
> 
> Bye,
> bearophile



More information about the Digitalmars-d mailing list