const by default.

kris foo at bar.com
Fri Jul 7 22:26:21 PDT 2006


Brad Roberts wrote:
> Walter Bright wrote:
> 
>> class C { int m; }
>>
>> void bar(C c) { c.m = 3; } // ok
>>
>> void foo(in C c) { bar(c); } // ok
> 
> 
> I have a problem with this chain..  Foo shouldn't be allowed to pass a 
> const thing into a function that wants a mutable thing.

Brad ~ you might be interested in the thread over in d.learn?

The premise is that, assuming readonly arrays can be supported, 
everything else can be made readonly via encapsulation and accessor 
methods. It would tend to make for a pretty simple implementation, along 
with simple rules?

The thread is called "read only array reference", but perhaps should be 
called "bang for the buck" instead



More information about the Digitalmars-d mailing list