Updated at: 2023-11-17
Brook needs to add programmable functions, so that scripts can be used to flexibly control the entire process in a programmatic manner. Lua and JavaScript were considered during the period, but after deliberation, it was found that both were relatively complicated and not simple enough. So I was going to write a scripting language to implement a few simple functions, such as types, process control, and functions. Then I found Tengo, which basically met my expectations, so I chose Tengo. The following is an introduction to this scripting language, which has almost no learning cost and can be used in a few minutes.
a := "foo" // string
b := -19.84 // floating point
c := 5 // integer
d := true // boolean
e := [1, 2, 3] // array
f := {a: 1, b: 2} // map
if c == 1 {
//
} else if c == 2 {
//
} else {
//
}
for i:=0; i<10; i++ {
//
}
add := func(a, b){
return a + b
}
c := add(1, 2)
It can be seen that functions are also a value type, just like defining a variable, which is pretty good
len(e)
more builtin functions
fmt := import("fmt")
fmt.println("hello")
The library is to package a series of functions and give them a name, more standard library
https://github.com/txthinking/bypass/blob/master/example_script.tengo
https://www.txthinking.com/shiliew.html