Aug 13, 2022Kuina-chan


This is the language specification 15 of Kuin Programming Language, and is about the other specifications of Kuin.

1Compile-time Constant

In Kuin, there are places where compile-time constant should be described, such as expressions specified in const and enum elements. This section explains what values can be made constants at compile time.

1.1Most Literals



Most literals become constants at compile time. However, array literals other than string types (e.g. "[1, 2, 3]") and function literals are excluded.
For example, all the literals in Figure 1-1 become constants at compile time.
  • 256
  • 3.14159
  • 'A'
  • true
  • 255b8
  • "abc"
  • ['a', 'b', 'c']
  • %enumElementName
  • null
Figure 1-1: Example Of Compile-time Constant

1.2Operations Between Constants



For some operations on constants, the result is guaranteed to be a constant. For example, addition of constants is guaranteed to result in a constant, and "5 + 3" is a compile-time constant.
See the description of each item in Operators to know which operation results in a constant.

2Directory Where Program Is Run From Kuin Editor

When running a program from the Kuin Editor, the current directory and resource directory are handled differently in debug mode than in release mode for convenience(Table 2-1).
Table 2-1: Handling Of Directories
Directory Debug Mode Release Mode
Initial State Of The Current Directory The directory containing the .kn file. The current directory.
"res/File Path" In the res directory at the location of the .kn file. In the res.knd file located in the exe location.
In release mode, the current directory will be the main focus, but when debugging, the program will work in such a way that the .kn location where resources exist will be the main focus. This is to prevent the need to copy the resource file every time the program is run for debugging.
Therefore, it is recommended to write as shown in Table 2-2 when accessing the file.
Table 2-2: How To Access The Files
File Type Way Of Writing
Files In The Current Directory "File Path"
Files In The Directory Containing exe wnd@exeDir() ~ "File Path"
Resource Files "res/File Path"
If you run the program in debug mode without saving the .kn file, or if you use the console version of the Kuin compiler directly without using the Kuin Editor, the behavior will be the same in debug mode as in release mode.
1660385422enf