View Single Post
  #4 (permalink)  
Old January 9th, 2009, 11:30 PM
Old Pedant Old Pedant is offline
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default WARNING: Pedanticism, again

Again, Dr. Purdum's answer is just fine for those starting out. And if I wasn't such a [censored] I'd leave it alone. But for those who might be "up one level," once again the devil is in the details.

Don't think of static data as global is not.

True, but if a static member is public, it's hard to consider that it is in any real way *not* "global data."

Why did Microsoft do it this way?

Yes. But why stop with Microsoft? Why do so many modern languages do it this way? And even some not-quite-so-modern ones, such as C.

... Because Visual Studio knows that any static data item defined anywhere...

I guess so. Sort of. But shouldn't we REALLY say "...because the C# compiler knows..."??? I mean, I doubt that the other parts of VS--the ones that show the pretty graphics and allow database connections and the editor and so on and so on have any knowledge at all of the working of any given compiled program.

Also, all static data are defined the instant the program is loaded into memory.

I know this is just a slip of the wording. Static data is of course *reserved* when the program is loaded into memory. But it won't be "defined" (that is, contain usable data) until something in your program initializes it. [The exceptions are static initialized members, of course.]


Hope you don't mind too much my being a pain in the patootie.

And KHYOON, if you are reading this, you should ignore this level of detail. Come back in a year or so and my remarks will make more sense to you, I bet.