Public and private functions

A function is public by default, meaning that it can be called from any Gosu code. In contrast, a private function can be called only within the library in which it is defined. For example, suppose you have the following two functions defined in a library:

public function funcA() {
  ...
}

private function funcB() {
  ...
}

Because funcA() is defined as public, it can be called from any other Gosu expression. However, funcB() is private, and therefore is not valid anywhere except within the library.

For example, a function in another library could call funcA(), but it could not call the private funcB(). Because funcA() is defined in the same library as funcB(), however, funcA() can call funcB().

Do not make any function public without good reason. Therefore, mark a function as private if it is defined only for use inside the library.

See also