List for cgit developers and users
 help / color / mirror / Atom feed
* Policy on global variables
@ 2014-01-16  0:06 Jason
  2014-01-16  0:20 ` Jason
  2014-01-16  0:59 ` normalperson
  0 siblings, 2 replies; 15+ messages in thread
From: Jason @ 2014-01-16  0:06 UTC (permalink / raw)


Hi guys,

Major question tormenting my cgitified soul...

Sometimes we use a global ctx variable. Other times we do not. It
appears that the global usage is more common, but that there's some
nice logic for passing around the ctx variable to function to function
as an argument or even in callback functions.

In theory, passing around the variable, and not relying on a global,
is better. It allows us at somepoint to have multiple contexts, for,
say, implementing FastCGI or an event loop single-process multi
response model. On the other hand, it's messier and uglier and harder
to deal with. And beyond ctx, we use several other globals in various
places.

After discussing this with him, Lukas whipped up a massive patch-set
(which I squashed down) that removes the parameter passage usage of
ctx and uses only globals:
http://git.zx2c4.com/cgit/commit/?h=lf/global-ctx

I'm torn over whether or not to merge this. It's a lot of nice careful
C that went in to the non-global references, and it seems like a shame
to trash that. A part of me feels like we should work on the opposite
patch -- where we get rid of all global variables. On the other hand,
maybe that's an unrealistic expectation, and we should instead
standardize on the global approach, and merge this patch.

I'd appreciate it if you all weighed in on this topic. I'm very torn
and am changing my mind every couple of seconds. What do you think?

Thanks,
Jason

On Wed, Jan 15, 2014 at 10:37 PM, Lukas Fleischer <cgit at cryptocrack.de> wrote:
> Jason noticed that sometimes, we pass a reference (pointer) to the
> global context variable. This series removes all such references and
> replaces them with direct use of the global variable.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-01-16 23:42 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-16  0:06 Policy on global variables Jason
2014-01-16  0:20 ` Jason
2014-01-16  0:59 ` normalperson
2014-01-16  1:00   ` Jason
2014-01-16  8:06     ` hjemli
2014-01-16 10:47       ` normalperson
2014-01-16 11:31         ` Jason
2014-01-16 13:08           ` john
2014-01-16 18:38             ` Jason
2014-01-16 21:21               ` john
2014-01-16 21:26                 ` Jason
2014-01-16 21:34                   ` john
2014-01-16 21:36                     ` Jason
2014-01-16 22:20                       ` john
2014-01-16 23:42                         ` Jason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).