WTF! new in class is static?!?!
bauss
jj_1337 at live.dk
Sat Jun 9 11:47:54 UTC 2018
On Saturday, 9 June 2018 at 09:24:48 UTC, KingJoffrey wrote:
> On Thursday, 7 June 2018 at 21:57:17 UTC, Steven Schveighoffer
> wrote:
>>
>> Yep, long-standing issue:
>> https://issues.dlang.org/show_bug.cgi?id=2947
>>
>> Almost a decade old!
>>
>> -Steve
>
> Another reason why I still refuse to bring my code to D.
>
> As if the module not respecting class encapsulation was not
> enough (see my rants about it elsewhere), D even allows two
> class instances to share non static mutable data!!
>
> wtf!
>
> --------------
> import std.stdio;
>
> class A
> {
> int[] c = [3,3];
> }
>
> void main()
> {
> A ca = new A;
> A cb = new A;
>
> ca.c[0] = 44;
>
> writeln(cb.c[0]);
> // prints 44!!!! (in C++, Java and C#, this would -
> correctly - print 3)
> }
> ---------------
Nobody cares about your opinion.
Nobody is forcing you to write code like that.
In fact most programs will be written without such code, for good
reason.
Regardless if it does the "correct" thing or not.
More information about the Digitalmars-d-learn
mailing list