Aug 13, 2022Kuina-chan

This is the language specification 1 of Kuin Programming Language, and is about naming and reserved words.

1Kuin Naming Rules

Many programming languages have inconsistent abbreviations for words in function and variable names, and use different words for the same concept. These are extra complicated for users.
Therefore, Kuin has established guidelines for naming methods to ensure that the naming is as consistent as possible, and the standard library will follow these guidelines. This is called the Kuin Naming Rules.
In this section, I will introduce the Kuin naming rules one by one.

1.1Characters That Can Be Used In Names

The only characters that can be used for Kuin identifiers are alphanumeric characters and "_", which must start with a non-numeric character.
And, the only characters that can be used in file names are lowercase letters, numbers, and "_", and the beginning must be non-numeric.

1.2Uppercase And Lowercase Rules

Kuin distinguishes between uppercase and lowercase letters in the source code as different characters. The Kuin naming rules specify the use of uppercase and lowercase letters, as shown in Figure 1-1.
  • Basically, name the word in lower case, and capitalize the beginning of the second and subsequent words when multiple words are concatenated.
  • Abbreviations consisting of acronyms, such as "XML," are considered to be a single word in their entirety.
Figure 1-1: Uppercase And Lowercase Rules
For example, "exampleCorrectName" and "readXml".
Reason For The Design

This rule is called camelcase, and the reason for this rule is that it reduces both the number of types and the amount of code.

It is also common to have different naming rules for global and local variables to avoid conflicts, but Kuin has a syntax rule that global variables should be prefixed with "@", so we use camelcase to unify them.

1.3Type Name Prefix Rules

Enumeration types and class types are named as shown in Figure 1-2.
  • The first letter of user-defined type names, such as enumerated type names and class names, should be capitalized.
Figure 1-2: Type Name Prefix Rules
For example, if you want to define an enumerated type called "example color," you would name it "ExampleColor." And define it's variables as "exampleColor" and so on.
Reason For The Design

There are often cases where we define a class and want to create a variable with the same name as it, so we use this rule to prevent name conflicts in such cases.

1.4Source Code Naming Rules

In Kuin, when referring to other source code, the source code name is sometimes written in a source code, and in this case, the source code name is written according to the rule shown in Figure 1-3.
  • Source code names should be named in all lowercase.
  • When multiple words are concatenated, place a "_" between each word.
Figure 1-3: Source Code Naming Rules
For example, it could be "example_kuin_code".
Reason For The Design

Windows does not distinguish between upper and lower case letters in file names, so the same file "ABC" could be treated as a different file "abc" or "Abc", which could cause problems. Therefore, I decided to use lower case for all file names.

1.5Abbreviation Rules

Programmers have often written words in abbreviations to reduce the number of types and shorten the code as much as possible. However, as each of them abbreviated words in their own way, the original words often became unrecognizable.
Therefore, the Kuin naming rules has established the Kuin Abbreviation Dictionary, which lists common abbreviations of words, and provides a guideline that words in this dictionary must be used in this abbreviation.
The criteria for abbreviations are shown in Figure 1-4.
  • Do not abbreviate words of four letters or less.
  • Abbreviate words that appear frequently in programming.
  • Words that are often abbreviated conventionally are abbreviated.
  • If the abbreviation duplicates or obscures the original word, do not abbreviate or use a different synonym.
Figure 1-4: Abbreviation Rules
Reason For The Design

If we didn't abbreviate words at all, there would be no risk of confusion, but the longer the program, the more complicated it becomes and the harder it is to grasp, so I decided to abbreviate as much as possible.

2Kuin Reserved Words

Some words are reserved words and cannot be used as identifiers for variable or function names.
All of Kuin reserved words are shown in Table 2-1.
Table 2-1: Kuin Reserved Words
alias assert bit16 bit32
bit64 bit8 block bool
break case catch char
class const dbg default
dict do elif else
end enum env excode
false finally float for
func if include inf
int list me null
queue ret skip stack
super switch throw to
true try var while
Reason For The Design

Kuin is syntactically distinguishable between identifiers and non-identifiers, so it is actually not a problem to allow "if", "for", etc. as variable names. However, the use of "if" in variable names is still a source of confusion, so I prohibited it as a reserved word.