Cours the implementation of lua 5.0

Extrait du  cours the implementation of lua 5.0

1 Introduction
Lua was born in an academic laboratory as a tool for in-house software development but somehow was adopted by several industrial projects around the world and is now widely used in the game industry.
How do we account for this widespread use of Lua? We believe that the answer lies in our design and implementation goals: to provide an embeddable scripting language that is simple, ecient, portable, and lightweight. These have been our main goals since the birth of Lua in 1993 and they have been respected during its evolution. (For a history of the development of Lua up to just before the release of Lua 5.0, see [12].) These features, plus the fact that Lua has been designed from the start to be embedded into larger applications, account for its early adoption by the industry.
2 An Overview of Lua’s Design and Implementation
As mentioned in the introduction, the goals in our implementation of Lua are:
Simplicity : We seek the simplest language we can a ord and the simplest C code that implements this language. This implies a simple syntax with a small number of language constructs, not far from the tradition.
Eciency : We seek fast compilation and fast execution of Lua programs. This implies a fast, smart, one-pass compiler and a fast virtual machine.
Portability : We want Lua to run on as many platforms as possible. We want to be able to compile the Lua core unmodi ed everywhere and to run Lua pro-grams unmodi ed on every platform that has a suitable Lua interpreter. This implies a clean ANSI C implementation with special attention to portability issues, such as avoiding dark corners of C and its libraries, and ensuring that it also compiles cleanly as C++. We seek warning-free compilations.
Embeddability : Lua is an extension language; it is designed to provide scripting facilities to larger programs. This and the other goals imply the existence of a C API that is simple and powerful, but which relies mostly on built-in C types.
3 The Representation of V alues
Lua is a dynamically-typed language: types are attached to v alues rather than to v ariables. Lua has eight basic types: nil, boolean, number, string, table, function,userdata, and thr ead. Nil is a marker type having only one v alue, also callednil. Boolean v alues are the usual true and false. Numbers are double-precision oating-point numbers, corresponding to the type double in C, but it is easy to compile Lua using float or long instead. (Several games consoles and smaller machines lack hardware support for double.) Strings are arrays of bytes with an explicit size, and so can contain arbitrary binary data, including embedded zeros. T ables are associative arrays, which can be indexed by any v alue (except nil) and can hold any v alue. F unctions are either Lua functions or C functions written according to a protocol for interfacing with the Lua virtual machine. Userdata are essentially pointers to user memory blocks, and come in two avors: heavy, whose blocks are allocated by Lua and are sub ject to garbage collection, and light, whose blocks are allocated and freed by the user. Finally , threads represent coroutines. V alues of all types are rst-class v alues: we can store them in global v ariables, local v ariables and table elds, pass them as arguments to functions, return them from functions, etc.

……….

Si le lien ne fonctionne pas correctement, veuillez nous contacter (mentionner le lien dans votre message)
Cours the implementation of lua 5.0 (265 KO) (Cours PDF)
The implementation of lua

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *