38

Why would anyone declare a private static function ???? Like WTF????

Comments
  • 0
    I never use private because I am always developing in C but with static you can have a function pointer to it thus giving you external access. Is it the same?
  • 15
    to call it from a public static method?
  • 7
    You are too self::ish.
  • 0
    @jarnix The PHP guys are here
  • 0
    @jonjo
    That's better. With a private static function, you are removing access to the function from any external or internal Object
  • 7
    Why would anyone add tags at DevRant as You did???!!!! Like WTF?! 😀
  • 0
    just upvoted for naughty linus
  • 2
    Yeah, to call it from a public static function is the main reason.

    Sometimes you want to encapsulate/organize functionality but not actually expose it on the interface of the object.
  • 5
    Singleton, anyone? 🙄
  • 2
    Nothing wrong with having a private static function. Maybe you want to keep some logics separate from the public interface
  • 1
    @jonjo I am afraid not. The new languages dont let people do the wonderful things C can. I am pretty sure everyone would be in bliss if they could throw type safety out of the window on demand or intertwine a switch and a while loop or just do everything the guys over at IOCCC do 😀
  • 1
    @magnusi is why I love C
  • 1
    It's funny because Linus absolutely despises C++! 😂
  • 0
    Useful if you want to let everybody know that this method does not change object's state and its usage is restricted to this class.
Add Comment