3 ms·
'static' in C is the worst - it has 2 different meanings within the same language. Does anyone know the reason for this confusing design decision?
by iamaleksey 16y ago
'static' in C is the worst - it has 2 different meanings within the same language. Does anyone know the reason for this confusing design decision?
- dfox 16y agoReason for this is that static actually does exactly same thing in both cases: defines global variable without externally accessible name and makes it accessible in enclosing scope. (exact standarteese being "internal linkange with static storage duration")
- alextgordon 16y agoIt's actually quite remarkable the number of places a single keyword can be used. We have * Static functions in C * Static variables in C * Static members in C++ * Static instance variables in Java * Static methods in Java The strange combination of C++'s namespaces and static begets static members, which almost make sense in context. But then Java stole the syntax and not the rest of the language (thank god), leading to its strange, almost contradictory usage.
- pivo 16y agoIn Java there are also static inner classes and static initializers (static code blocks that initialize static data)