On Tue, May 30, 2006 at 04:55:14PM +0300, Denis Doroshenko wrote:
> 
> why would you even want that (moreover in opensource)? hide for what reason?
> 

It's called lexical scoping - it has nothing really to do with
security more to do with preventing namespace pollution.  Clearly you
have never written a library.  By scoping functions static you are
indicating that the functions are private and are not part of the
interface available for use.  You do this actually to protect the
users of your code - you don't need to care about namespace clashes
e.g. you can call the internal function next_one() without fear, if
the function is not statically scoped then you would have to prefix
the function with __mylib_next_one() or suchlike otherwise a consumer
of your library would get a duplicate symbol if they created their own
function next_one(), or even worse the consumer's function will be
called by the library internals... no doubt doing the wrong thing.

Secondly it means that you, as the library creator, are able to change
the internal interfaces at whim without needing to be concerned about
the impact on the consumers of your library.  Sure, people can modify
the source and remove the static from the function but that this point
they are lining a gun up on their foot with their finger on the
trigger - if they happen to put a bullet through their foot they have
noone to blame but themselves.

Again, it's not a security issue - it's a usuability/api issue.

-- 
Brett Lymn

Reply via email to