QtD is suspended

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Sep 17 10:23:50 PDT 2010


On 9/17/10 12:04 CDT, Steven Schveighoffer wrote:
> On Fri, 17 Sep 2010 12:44:30 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 9/17/10 10:48 CDT, Michel Fortin wrote:
>>> I understand the intent quite well. I'm talking about what happens if
>>> the source is const?
>>
>> The whole point is, mutation is the motivator. If you copy an empty
>> hash, no problem because the receiver can't mutate it.
>
> yeah, but he can read it:
>
> struct S
> {
> int[int] hash;
> const(int[int]) getHash() const { return hash; }
> }
>
> void main()
> {
> S s;
> auto h = s.getHash();
> s.hash[1] = 1;
> assert(1 in h); // fails
> }
>
> -Steve

Good point!

Andrei


More information about the Digitalmars-d-announce mailing list