Why people dislike global variables so much while I find them so convenient?

rempas rempas at tutanota.com
Wed Jan 26 08:02:33 UTC 2022


On Tuesday, 25 January 2022 at 12:56:00 UTC, max haughton wrote:
> What I mean by outline (where global is the thing you don't 
> like passing around) :
>
>     ```d
>     int foo(ref int global)
>     {
>         bar(global);
>     }
>     int bar(ref int global);
>     ```
>     the "outline" (a reduced call graph if you will) would be 
> something like
>
>     ```
>     foo(ref int global)
>       bar(global);
>     ```
>     if the code is small enough just post the code, I want to 
> illuminate that if you have a bunch of parameters everywhere 
> you might want to make it a member function instead.

Oh, thanks for the explanation! No, the code is not small, it is 
a bunch of functions that access them actually. What do you mean 
with "member function". In a class?


More information about the Digitalmars-d mailing list