static methods

Grant Edwards grante at visi.com
Sat Mar 24 18:40:00 EST 2001


In article <7h1qbt8h8aos1parc090s8tqu2ooc04t4d at 4ax.com>, Courageous wrote:

>>That it's called "static" is an artifact of C, I believe. In C, "static" 
>>has been overexploited such that it has many different meanings in 
>>different contexts that have nothing to do with being "static". Hideous 
>>example: declaring a function as "static" in C means that it's invisible to 
>>code outside of the source file and to all code following it in the same 
>>file. :-0
>
>Hrm. I'd forgotten that. In languages where there are no namespaces,
>it's useful to be able to make certain that symbols don't go out and
>pollute the global namespace in which ALL symbols reside. This is
>what that's for.

I'm confused -- are you saying that C doesn't have namespaces?

>More generally, "static" in most cases in C and C++ means "global
>for the scope that I'm in", err, well, sortof.

:)

In C, the keyword "static" is used for two separate, orthogonal purposes:

 1) to define the lexical scope of a variable.

 2) to define the storage lifetime of a variable. 

There is no excuse for using the same keyword to mean two unrelated things.

-- 
Grant Edwards                   grante             Yow!  Used staples are good
                                  at               with SOY SAUCE!
                               visi.com            



More information about the Python-list mailing list