Why people dislike global variables so much while I find them so convenient?
rempas
rempas at tutanota.com
Tue Jan 25 11:41:55 UTC 2022
On Tuesday, 25 January 2022 at 10:18:50 UTC, bauss wrote:
> The problem with globals is that anyone and anything can modify
> it.
>
> It becomes especially problematic when your program receives
> input from elsewhere such as connections like sockets, http
> etc. or even other threads.
>
> In my opinion globals are fine IFF they're only initialized
> once (and only one place is allowed to modify them) and/or
> they're immutable
>
> Globals are extremely convenient to use and that's also why
> they're extremely dangerous to use.
This will be a big problem with libraries but I don't see it been
a big problem with non-library type applications. At least if I
understand correctly what you are saying (which I probably don't).
More information about the Digitalmars-d
mailing list