News for hackers. Stuff that matters.
Re:There are three different meanings for the static keyword... by zeteo on Monday August 23, 2010 @01:33AM (#1625965)
It's somewhat ungainly, but one way to think about this is that "static" means "it stays here".

In a function: the value of the variable stays with the function, i.e. it doesn't change between calls.

In a class: the value of the variable stays with the class, i.e. it doesn't change with the creation of new objects.

In a file: the value of the variable stays within the file, i.e. it can't be changed (or seen) from outside the file.

Re:There are three different meanings for the static keyword... by cema on Monday August 23, 2010 @12:44AM (#1625877)
No pain, it is simply reused.
Re:There are three different meanings for the static keyword... by KeithMajhor on Monday August 23, 2010 @02:31AM (#1626027)
As far as I know, a language with less keywords lends itself to a faster parser. That's the motivation behind using "auto" for type inference in C++0x, "auto" is already a keyword.
Re:There are three different meanings for the static keyword... by pbhogan on Monday August 23, 2010 @08:05AM (#1626528)
The difference is negligible. Complexity of grammar (not the same thing) is probably the big cost factor. The big thing there is usually ambiguity of a statement within a single context that has to be resolved. Static is not such a case because there are three distinct contexts. But when a parser has to read many tokens ahead just to figure out where you're going with a term, that's what slows things down.
Re:There are three different meanings for the static keyword... by pbhogan on Monday August 23, 2010 @08:02AM (#1626524)
At least the third meaning is deprecated in favor of anonymous namespaces.

The other two are essentially the same just within class or function scope. Of course, they're essentially just global state of a sort, but they sure do come in useful at times.

Re:There are three different meanings for the static keyword... by jpr on Monday August 23, 2010 @01:49AM (#1625980)
If this is "real pain", I wonder what some of the weirder stuff of C++ would be, "surreal pain"?
Re:There are three different meanings for the static keyword... by pbhogan on Monday August 23, 2010 @08:03AM (#1626525)
Indeed. This is mild. I've never been confused by a static keyword.

Now some templates, on the other hand, seem to be from another dimension.