4.1. Lua tutorial

发布时间 :2023-10-12 23:00:03 UTC      

Lua

Lua is a lightweight and compact scripting language written in the standard C language and open in source code. It is designed to be embedded in the application so as to provide flexible extension and customization for the application.

Lua was developed in 1993 by a research team at the Catholic University (Pontifical Catholic University of Rio de Janeiro) in Rio de Janeiro, Brazil. The team members are Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo.

4.1.1. Design purpose #

It is designed to be embedded in the application, so as to provide flexible extension and customization for the application.

4.1.2. Lua characteristics #

  • Lightweight: it is written in standard C language and open in source code. After compilation, it is only more than 100 K, and can be easily embedded inother programs.

  • Extensibility: Lua provides very easy-to-use extension interfaces and mechanisms: these functions are provided by the host language (usually C or C++) and can be used by Lua as if they were built-in functionality.

  • Other features:

    • Support for process oriented (procedure-oriented) programming and functionalprogramming (functional programming);

    • Automatic memory management; only one common type of table (table) is provided, which can be used to implement arrays, hash tables, collections, and objects:

    • Language built-in pattern matching; closure; function can also be seen as a value; provides multithreading (collaborative processes, not threads supported by the operating system)

    • Closures and table can easily support some of the key mechanisms needed for object-oriented programming, such as data abstraction, virtual functions, inheritance and overloading.

4.1.3. Lua application scenario #

  • Game development

  • Stand-alone application script

  • Web application script

  • Extensions and database plug-ins such as MySQL Proxy and MySQL WorkBench

  • Security systems, such as intrusion detection systems

4.1.4. The first Lua program #

Next, we use the Lua to output "Hello World!"

Instance (Lua 5.3) #

print("Hello World!")

After running, it will be displayed on the screen Hello, world! .

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.