opDispatch and compile time parameters
Marc Schütz via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 20 04:36:35 PDT 2015
On Tuesday, 20 October 2015 at 01:49:08 UTC, Jonathan M Davis
wrote:
> On Monday, 19 October 2015 at 23:37:09 UTC, Timon Gehr wrote:
>> This is the worst part:
>>
>> class C{
>> int[] x=[1,2,3];
>> }
>>
>> void main(){
>> auto mut=new C;
>> auto imm=new immutable(C);
>> assert(imm.x[0]==1);
>> mut.x[0]=2;
>> assert(imm.x[0]==2);
>> }
>
> Oooo. Ouch. Yeah, that pushes it from being a good idea to
> disallow this in order to avoid bugs to a necessity to disallow
> it in order to avoid breaking the type system.
Yeah. But IMO it should still be allowed for immutable objects,
and the error/deprecation message should say so, because for
those it can actually be useful and there would be no other way
to do it.
More information about the Digitalmars-d
mailing list