Why people dislike global variables so much while I find them so convenient?
forkit
forkit at gmail.com
Tue Jan 25 23:28:36 UTC 2022
On Tuesday, 25 January 2022 at 09:53:25 UTC, rempas wrote:
>
> So can someone make examples about how global variables can
> mess me up. I know that probably everyone here has more
> personal experience than me so I really want to learn why
> global variables are considered so harmful.
// ---
module test;
import std;
int x = 0;
void main()
{
writeln(foo);
}
int foo()
{
int x = 10;
if(x) // ooh. you sure this was your intention??
return x;
else
return .x;
}
// ---
More information about the Digitalmars-d
mailing list