0% found this document useful (0 votes)
31 views

Download Complete Programming in Lua 4th Edition Roberto Ierusalimschy PDF for All Chapters

Roberto

Uploaded by

nuquiursinh7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Download Complete Programming in Lua 4th Edition Roberto Ierusalimschy PDF for All Chapters

Roberto

Uploaded by

nuquiursinh7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Get ebook downloads in full at ebookmeta.

com

Programming in Lua 4th Edition Roberto


Ierusalimschy

https://ebookmeta.com/product/programming-in-lua-4th-
edition-roberto-ierusalimschy/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

LÖVE for Lua Game Programming 1st Edition Akinlaja Darmie

https://ebookmeta.com/product/love-for-lua-game-programming-1st-
edition-akinlaja-darmie/

ebookmeta.com

Lua Programming The Ultimate Beginner s Guide to Learn Lua


Step by Step Claudia Alves & Alexander Aronowitz [Alves

https://ebookmeta.com/product/lua-programming-the-ultimate-beginner-s-
guide-to-learn-lua-step-by-step-claudia-alves-alexander-aronowitz-
alves/
ebookmeta.com

Competitive Programming 4 The Lower Bound of Programming


Contests in the 2020s 4th Edition Steven Halim

https://ebookmeta.com/product/competitive-programming-4-the-lower-
bound-of-programming-contests-in-the-2020s-4th-edition-steven-halim-2/

ebookmeta.com

Alpha s Redemption My Luna Has A Son Regret Series 2 1st


Edition Jessica Hall

https://ebookmeta.com/product/alpha-s-redemption-my-luna-has-a-son-
regret-series-2-1st-edition-jessica-hall/

ebookmeta.com
The Irish Presbyterian Mind: Conservative Theology,
Evangelical Experience, and Modern Criticism, 1830-1930
Holmes
https://ebookmeta.com/product/the-irish-presbyterian-mind-
conservative-theology-evangelical-experience-and-modern-
criticism-1830-1930-holmes/
ebookmeta.com

Tactile Sensing, Skill Learning, and Robotic Dexterous


Manipulation 1st Edition Qiang Li (Editor)

https://ebookmeta.com/product/tactile-sensing-skill-learning-and-
robotic-dexterous-manipulation-1st-edition-qiang-li-editor/

ebookmeta.com

African American Art a Visual and Cultural History 1st


Edition Lisa Farrington

https://ebookmeta.com/product/african-american-art-a-visual-and-
cultural-history-1st-edition-lisa-farrington/

ebookmeta.com

Brooks Brothers in Arms in Alaska 5 1st Edition Kali Hart

https://ebookmeta.com/product/brooks-brothers-in-arms-in-alaska-5-1st-
edition-kali-hart/

ebookmeta.com

The Emergence of Corporate Governance People Power and


Performance 1st Edition Knut Sogner

https://ebookmeta.com/product/the-emergence-of-corporate-governance-
people-power-and-performance-1st-edition-knut-sogner/

ebookmeta.com
International Energy Law 2nd Edition Mohammad Naseem

https://ebookmeta.com/product/international-energy-law-2nd-edition-
mohammad-naseem/

ebookmeta.com
Last update: Sat Mar 18 22:00:08 GMT 2017 (build 21)

Programming in Lua, Fourth Edition

Roberto Ierusalimschy

Programming in Lua, Fourth Edition

Roberto Ierusalimschy

Copyright © 2016, 2003 Roberto Ierusalimschy

Feisty Duck Digital


Book Distribution
www.feistyduck.com

Licensed for the exclusive use of:

Eric Taylor <jdslkgjf.iapgjflksfg@yandex.com>

Table of Contents

About the Book


....................................................................................................
............. ix

I. The Basics
....................................................................................................
.................. 1

1. Getting Started
....................................................................................................
.... 4

Chunks
....................................................................................................
.......... 4

Some Lexical Conventions


................................................................................... 6

Global Variables
................................................................................................. 7

Types and Values


................................................................................................ 7
Nil
....................................................................................................
........ 8

Booleans
....................................................................................................
8

The Stand-Alone Interpreter


.................................................................................. 9

2. Interlude: The Eight-Queen Puzzle


............................................................................ 12

3. Numbers
....................................................................................................
........... 15

Numerals
....................................................................................................
...... 15

Arithmetic Operators
.......................................................................................... 16

Relational Operators
.......................................................................................... 17

The Mathematical Library


................................................................................... 18

Random-number generator
.......................................................................... 18

Rounding functions
.................................................................................... 18
Representation Limits
......................................................................................... 19

Conversions
....................................................................................................
.. 21

Precedence
....................................................................................................
... 22

Lua Before Integers


........................................................................................... 22

4. Strings
....................................................................................................
............. 24

Literal strings
....................................................................................................
24

Long strings
....................................................................................................
. 25

Coercions
....................................................................................................
..... 26

The String Library


............................................................................................. 27

Unicode
....................................................................................................
....... 29
5. Tables
....................................................................................................
.............. 33

Table Indices
....................................................................................................
33

Table Constructors
............................................................................................. 35

Arrays, Lists, and Sequences


............................................................................... 36

Table Traversal
.................................................................................................
38

Safe Navigation
.................................................................................................
38

The Table Library


............................................................................................. 39

6. Functions
....................................................................................................
.......... 42

Multiple Results
................................................................................................ 43

Variadic Functions
............................................................................................. 45

The function table.unpack


............................................................................ 47
Proper Tail Calls
............................................................................................... 48

7. The External World


................................................................................................ 50

The Simple I/O Model


....................................................................................... 50

The Complete I/O Model


.................................................................................... 53

Other Operations on Files


................................................................................... 54

Other System Calls


............................................................................................ 55

Running system commands


......................................................................... 55

8. Filling some Gaps


..................................................................................................
57

Local Variables and Blocks


................................................................................. 57

Control Structures
.............................................................................................. 58

if then else
............................................................................................... 58

while
....................................................................................................
... 59
iii

Programming in Lua, Fourth Edition

repeat
....................................................................................................
. 59

Numerical for
........................................................................................... 60

Generic for
.............................................................................................. 60

break, return, and goto


..................................................................................... 61

II. Real Programming


....................................................................................................
..... 65

9. Closures
....................................................................................................
........... 68

Functions as First-Class Values


............................................................................ 68

Non-Global Functions
........................................................................................ 69

Lexical Scoping
................................................................................................ 71

A Taste of Functional Programming


..................................................................... 74
10. Pattern Matching
..................................................................................................
77

The Pattern-Matching Functions


........................................................................... 77

The function string.find


...................................................................... 77

The function string.match


.................................................................... 77

The function string.gsub


...................................................................... 78

The function string.gmatch


.................................................................. 78

Patterns
....................................................................................................
........ 78

Captures
....................................................................................................
....... 82

Replacements
....................................................................................................
83

URL encoding
.......................................................................................... 84

Tab expansion
........................................................................................... 86
Tricks of the Trade
............................................................................................ 86

11. Interlude: Most Frequent Words


............................................................................. 90

12. Date and Time


....................................................................................................
. 92

The Function os.time


..................................................................................... 92

The Function os.date


..................................................................................... 93

Date–Time Manipulation
.................................................................................... 95

13. Bits and Bytes


....................................................................................................
. 97

Bitwise Operators
.............................................................................................. 97

Unsigned Integers
.............................................................................................. 97

Packing and Unpacking Binary Data


..................................................................... 99

Binary files
....................................................................................................
. 101
14. Data Structures
...................................................................................................
104

Arrays
....................................................................................................
........ 104

Matrices and Multi-Dimensional Arrays


............................................................... 105

Linked Lists
....................................................................................................
107

Queues and Double-Ended Queues


..................................................................... 107

Reverse Tables
................................................................................................
108

Sets and Bags


.................................................................................................
109

String Buffers
..................................................................................................
110

Graphs
....................................................................................................
....... 111

15. Data Files and Serialization


.................................................................................. 114
Data Files
....................................................................................................
... 114

Serialization
....................................................................................................
116

Saving tables without cycles


...................................................................... 118

Saving tables with cycles


.......................................................................... 119

16. Compilation, Execution, and Errors


....................................................................... 122

Compilation
....................................................................................................
122

Precompiled Code
............................................................................................ 125

Errors
....................................................................................................
......... 126

Error Handling and Exceptions


.......................................................................... 127

Error Messages and Tracebacks


.......................................................................... 128

17. Modules and Packages


........................................................................................ 131
The Function require
.................................................................................... 132

iv

Programming in Lua, Fourth Edition

Renaming a module
................................................................................. 133

Path searching
......................................................................................... 133

Searchers
................................................................................................
135

The Basic Approach for Writing Modules in Lua


.................................................. 135

Submodules and Packages


................................................................................. 137

III. Lua-isms
....................................................................................................
............... 139

18. Iterators and the Generic for


................................................................................ 142

Iterators and Closures


....................................................................................... 142

The Semantics of the Generic for


....................................................................... 143

Stateless Iterators
............................................................................................. 145
Traversing Tables in Order
................................................................................ 146

True Iterators
..................................................................................................
147

19. Interlude: Markov Chain Algorithm


....................................................................... 149

20. Metatables and Metamethods


................................................................................ 152

Arithmetic Metamethods
................................................................................... 152

Relational Metamethods
.................................................................................... 155

Library-Defined Metamethods
............................................................................ 155

Table-Access Metamethods
............................................................................... 156

The __index metamethod


....................................................................... 156

The __newindex metamethod


................................................................. 157

Tables with default values


......................................................................... 158

Tracking table accesses


............................................................................. 159
Read-only tables
...................................................................................... 160

21. Object-Oriented Programming


.............................................................................. 162

Classes
....................................................................................................
....... 163

Inheritance
....................................................................................................
.. 165

Multiple Inheritance
......................................................................................... 166

Privacy
....................................................................................................
....... 168

The Single-Method Approach


............................................................................ 170

Dual Representation
......................................................................................... 170

22. The Environment


................................................................................................
173

Global Variables with Dynamic Names


............................................................... 173

Global-Variable Declarations
............................................................................. 174
Other documents randomly have
different content
back
back
back
back
back

You might also like