5.7. Naming conventions

Variable names in Kink have a syntactical role. A function in a function variable, which does not contain an upper case letter, can be called by its name, while a data variable cannot be directly called.

注釈

The distinction between function variables and data variables was inspired by the orthography of German language, where nouns are capitalized.

Variable names also can indicate their accessibility. For example, if a method name starts from _, the method is private.

This chapter describes other aspects of naming conventions of variables.

5.7.1. Words are separated by underscores

Words of variable symbols should be separated by an underscore _.

Examples: open_to_read, _make_config, More_lines?.

5.7.2. Only the first letter of a data variable should be capitalized

As a general rule, only the first letter of a data variable should be capitalized. Examples: X, Tree, Valid_arg?.

As an exception, a variable containing a module should be the end part of the module name. For example, kink/BIN module should be stored in BIN variable.

Example:

:BIN.require_from('kink/')

:Prefix <- BIN.of(0xca 0xfe 0xba 0xbe)
stdout.print_line(Prefix.repr)  # => (bin 0xca 0xfe 0xba 0xbe)

As another example, if a data variable refers to a symbol of a different programming language, it is permissible to have multiple uppercase letters. For example, a variable which represents Java class java.util.ArrayList can be named as ArrayList_class.

5.7.3. ? at the end of Bool variables and functions

A symbol of a data variable which contains a bool value, or a function which returns a bool value should end with ?.

Examples: Null?, More_lines?, is?, _valid_type?