3 ms·
It's not creative or guessing. If you write a function without "static" it means you intended for it to be called externally. It's not theoretical at all: Befo
by MichaelBurge 9y ago
It's not creative or guessing. If you write a function without "static" it means you intended for it to be called externally.
It's not theoretical at all: Before I saw this thread, I was in the middle of writing some Haskell that loads some non-main symbols from an object file derived from an executable's source code, and invokes them. People carefully mark which functions are or are not static to ensure their executables don't get bloated. I'd be very annoyed if my C compiler didn't take symbol visibility into account when optimizing, because I depend on it all the time.
- HelloNurse 9y agoIf I write a function without "static" it means I want to allow functions in other modules module to call it, it isn't implied that it will be actually called. Real life analogy: declaring a static function is like locking your car because you don't want it stolen: only hackers can access it through forbidden means. If instead you leave your nonstatic car parked in the street, open and with keys in the ignition, you are making it easy to steal (probably you want it to be stolen, there might be an UB corpse in the trunk you want to get rid of), but you cannot be sure that a thief will actually come along and take it away; you are just advertising that they should.