Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Harlem Globe Trotters

Name: Anonymous 2009-10-08 19:23

How does /prog/ feel about global variables?

Name: Anonymous 2009-10-08 19:25

>>1
As an assembly language programmer, this does not warrant a response from me.

Name: Anonymous 2009-10-08 19:26

>>1
Over-used due to bad languages, but nothing wrong where appropriate.

Name: Anonymous 2009-10-08 19:27

>>1
All variables should be global.  It's a waste of resources (both time and memory) to pass variables.

Name: Anonymous 2009-10-08 19:31

>>4
Hello FV

Name: Anonymous 2009-10-08 19:35

pig disgusting.
but necessary on occasion

Name: Anonymous 2009-10-08 19:35

Even in C, I don't use them much. Some global state is needed, but it should be used only when required. I prefer Lisp's "global"'s which are just symbols which are declared special(dynamic scope), which means they're like globals which you can override as needed. To get the same(not transparent as in Lisp) in C, you would have to implement the variables as a linked list and push when you bind a global, pop when you exit the context of that binding, peek at the top of of the list when you want to read the value, and write to the top when you want to assign to the variable, this also needs to be implemented on a per-thread basis by using thread local storage, and one global value for all threads as well. Okay, so doing globals `properly' is a PITA in lower-level languages. If you understand all the pitfalls, and understand when you should use them, then go ahead and do so.

Name: Anonymous 2009-10-08 20:07

Yeah nothing beats global variables if your a cowboy programmer like me. none of that Enterprise Bullshit.

Also I rarely make member variables of a class private. OH WA WA SOMEONE COULD MISUSE THEM.. MER MER MER ENCAPSULATION. What? Fuck off. Whining faggots.

Name: Anonymous 2009-10-08 20:11

>>8
Agreed.  If you don't know how to use them, don't touch them.  It's pointless having to write some workaround just because you can't change a variable because the other is afraid "You'll mess things up!"

Name: Anonymous 2009-10-08 20:13

I only use globals when it's appropriate for them to be used in Haskell's State Monad.

Name: Anonymous 2009-10-08 20:17

>>8-9
Referential transparency.

Name: Anonymous 2009-10-08 20:33

>>8
the `private/protected' keywords in SEPPLES and other similar languages are kind of meh, I prefer the way Lisp handles this: exported - You can just use as you wish.
unexported - You realize the author didn't mean this to be used and is an internal implementation detail. You have to type one more letter when using them, or you could forcefully import it and just use it normally.
I've had some cases where I had to use the internal state of some library, both in ENTERPRISE languages and in Lisp. In ENTERPRISE shit, I just had to do some nasty hacks to get my way (in C++ you can do some simple pointer trickery to get to them, in C# you can use Reflection or just edit the binary directly), in Lisp, I just use it while understanding that if it's not exported, it's supposed to be an internal thing, and I should be weary that it might change in the future.

Name: Anonymous 2009-10-08 21:39

One word unintended namespace clashing thread over

Name: Anonymous 2009-10-08 21:45

>>13
That's a bit more than one word, eh?

Name: Anonymous 2009-10-08 21:52

>>14
That's the joke.

Name: Anonymous 2009-10-09 2:08

>>14 is the joke.

Name: Anonymous 2010-11-26 0:40

Name: Anonymous 2010-12-25 19:49

Name: Anonymous 2013-05-30 2:33

DTIHDE__HIEM_AGGOE_RBEADCDKI_TTSO?

Name: Anonymous 2013-05-30 2:33

DTIHDE HIEM AGGOE RBEADCDKI TTSO?

Don't change these.
Name: Email:
Entire Thread Thread List