Policy on global variables

Jason A. Donenfeld Jason at zx2c4.com
Thu Jan 16 01:20:15 CET 2014

A stranger, "bone" in ##c on freenode:

At first:

bone: "do you not care about reentrancy?"

After some discussion:

bone: given the practical considerations, you'll probably introduce
bugs by passing a context around, so you might as well leave it until
you actually need reentrancy. but i would try to refactor the code
functions that only need a subset of data can be passed that without
needing the whole context. then later you can change the upper level
functions to receive a context instead of using a static

me: so the first step, move to all global. then later on, refactor
things to pass a reference around, but to less places?

bone: yeah, presumably you have some functions that are only called by
one parent function, so they only do a subset of the work, and if they
can work on data from the context via parameters instead of
implicitly, all the better. then the parent can update the context as
needed, eventually you can reduce the number of accesses to the
context, then the move to passing the context around becomes much
easier implement

More information about the CGit mailing list