Literals

From Onix OS Wiki
Jump to: navigation, search

The literal definition is used to describe the system in-variants. These definitions maintain their validity throughout the system. Similar to definitions. There is no need to use a parameter for a single variable. But for multiple variables, brackets and commas are the same as in functions.However, please do not confuse functions because they are system objects, not functions. Another feature is that they can change the definitions in the programming language.

Please do not change the static writing when using it, otherwise you will leave the system alone with an inseparable error.

Definition

literal name(args...){
....args and definitions....
}
name ("arg1","arg2",....)

or

name "single arg only"

The definition is simple "literal" can be used in two ways. The first use is like a function. The second is the single object and the variable. Every literal you type is a system function. It expands the system by replacing existing ones or bringing a new one. When using a single argument, you can leave a space and write the argument. If you have a lot of arguments, it must be separated by commas in parentheses. Otherwise, the system will fail.


Example

literal db(name){
	createdb(name)
}
db "database"
# => ...created db
literal writedb(name, key, data){
	insertdb(name, key, data)
}
writedb ("database", "olang", "Hello olang data struct!")
# => ...writed data

We have examined the use of two types. We changed "db()" to literali by shortening the existing "createdb()" function on first use. In the second case, we replaced the existing "insertdb()" function with "writedb()". It automatically writes information to the database every time it is called. We will provide details on this on the Database page. For now, let's keep this here as an example.