1 – 简介

原文:https://www.lua.org/manual/5.4/manual.html

1 – Introduction – 简介

Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

​ Lua 是一种强大、高效、轻量、可嵌入的脚本语言。它支持过程式编程、面向对象编程、函数式编程、数据驱动编程和数据描述。

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode with a register-based virtual machine, and has automatic memory management with a generational garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

​ Lua 将简单的过程语法与基于关联数组和可扩展语义的强大数据描述结构相结合。Lua 是动态类型的,通过使用基于寄存器的虚拟机解释字节码来运行,并具有带有代际垃圾回收的自动内存管理,使其非常适合配置、脚本编写和快速原型设计。

Lua is implemented as a library, written in clean C, the common subset of standard C and C++. The Lua distribution includes a host program called lua, which uses the Lua library to offer a complete, standalone Lua interpreter, for interactive or batch use. Lua is intended to be used both as a powerful, lightweight, embeddable scripting language for any program that needs one, and as a powerful but lightweight and efficient stand-alone language.

​ Lua 是作为库实现的,用干净的 C 语言编写,这是标准 C 和 C++ 的通用子集。Lua 发行版包括一个名为 lua 的宿主程序,它使用 Lua 库提供一个完整的独立 Lua 解释器,用于交互式或批处理使用。Lua 旨在用作任何需要它的程序的强大、轻量、可嵌入的脚本语言,以及用作强大但轻量且高效的独立语言。

As an extension language, Lua has no notion of a “main” program: it works embedded in a host client, called the embedding program or simply the host. (Frequently, this host is the stand-alone lua program.) The host program can invoke functions to execute a piece of Lua code, can write and read Lua variables, and can register C functions to be called by Lua code. Through the use of C functions, Lua can be augmented to cope with a wide range of different domains, thus creating customized programming languages sharing a syntactical framework.

​ 作为一种扩展语言,Lua 没有“主”程序的概念:它嵌入在称为嵌入程序或简单地称为主机的宿主客户端中工作。(通常,此主机是独立的 lua 程序。)宿主程序可以调用函数来执行一段 Lua 代码,可以写入和读取 Lua 变量,并且可以注册 C 函数以供 Lua 代码调用。通过使用 C 函数,可以对 Lua 进行扩充以应对各种不同的领域,从而创建共享语法框架的定制编程语言。

Lua is free software, and is provided as usual with no guarantees, as stated in its license. The implementation described in this manual is available at Lua’s official web site, www.lua.org.

​ Lua 是免费软件,并且按照其许可证中所述,照常提供,不提供任何保证。本手册中描述的实现可在 Lua 的官方网站 www.lua.org 上获得。

Like any other reference manual, this document is dry in places. For a discussion of the decisions behind the design of Lua, see the technical papers available at Lua’s web site. For a detailed introduction to programming in Lua, see Roberto’s book, Programming in Lua.

​ 与任何其他参考手册一样,本文档在某些地方很枯燥。有关 Lua 设计背后的决策的讨论,请参阅 Lua 网站上提供的技术论文。有关 Lua 编程的详细介绍,请参阅 Roberto 的书《Lua 编程》。

最后修改 January 31, 2024: 更新 (e0896df)