Function

This chapter introduces functions. There are two types of functions in Lua:

  • Lua function, defined in Lua;
  • External functions are generally implemented in the interpreter language. For example, in the official implementation of Lua, they are C functions; while in our case, they are Rust functions. For example, the print function at the beginning of this project was implemented in Rust in the interpreter.

The definition (syntax analysis) and call (virtual machine execution) of the former are both in the Lua language, and the process is complete, so the former will be discussed and implemented first. Then introduce the latter and related API.