Why people dislike global variables so much while I find them so convenient?
maxhaton at gmail.com
Wed Jan 26 15:10:44 UTC 2022
On Wednesday, 26 January 2022 at 08:02:33 UTC, rempas wrote:
> 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) :
>> int foo(ref int global)
>> int bar(ref int global);
>> the "outline" (a reduced call graph if you will) would be
>> something like
>> foo(ref int 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?
If a class is reasonable, use a class, however if it's just some
mutable state then use a struct since you don't need OOP
More information about the Digitalmars-d