Submitted by: Submitted by n0idea
Views: 532
Words: 83887
Pages: 336
Category: Science and Technology
Date Submitted: 07/24/2012 03:11 PM
Programming in Lua
ROBERTO IERUSALIMSCHY
edition
Lua.org
2nd
Last update: Wed Jan 13 12:07:33 UTC 2010
Programming in Lua
Property of Ian Bloss
Property of Ian Bloss
Programming in Lua Second Edition
Roberto Ierusalimschy
PUC-Rio, Brazil
Lua.org
Rio de Janeiro
Property of Ian Bloss
by Roberto Ierusalimschy ISBN 85-903798-2-5
Programming in Lua, Second Edition
Copyright c 2006, 2003 by Roberto Ierusalimschy. All rights reserved. The author can be contacted at roberto@lua.org. Book cover and illustrations by Dimaquina. Lua logo design by Alexandre Nako. A Typesetting by the author using LTEX. Although the author used his best efforts preparing this book, he assumes no responsibility for errors or omissions, or for any damage that may result from the use of the information presented here. All product names mentioned in this book are trademarks of their respective owners.
´ CIP – Biblioteca do Departamento de Informatica, PUC-Rio
I22
Ierusalimschy, Roberto Programming in Lua / Roberto Ierusalimschy. – 2nd ed. – Rio de Janeiro, 2006. xviii, 308 p. : 25 cm. Includes index. ISBN 85-903798-2-5 1. Lua (Programming language). 005.133 – dc20 I. Title.
Property of Ian Bloss
to Ida, Noemi, and Ana Lucia
Property of Ian Bloss
Property of Ian Bloss
Contents
Preface
xiii
I
1
The Language
1
Getting Started 3 1.1 Chunks 4 1.2 Some Lexical Conventions 5 1.3 Global Variables 6 1.4 The Stand-Alone Interpreter 7 Types and Values 9 2.1 Nil 10 2.2 Booleans 10 2.3 Numbers 10 2.4 Strings 11 2.5 Tables 13 2.6 Functions 17 2.7 Userdata and Threads
2
17
3
Expressions 19 3.1 Arithmetic Operators 19 3.2 Relational Operators 20 3.3 Logical Operators 21 3.4 Concatenation 22 3.5 Precedence 22 3.6 Table Constructors 22
vii
Property of Ian Bloss
viii
Contents
4
Statements 27 4.1 Assignment 27 4.2 Local Variables and Blocks 4.3 Control Structures 30 4.4 break and return 34...