WTF! new in class is static?!?!
KingJoffrey
KingJoffrey at KingJoffrey.com
Sat Jun 9 09:24:48 UTC 2018
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)
}
---------------
More information about the Digitalmars-d-learn
mailing list