Cours a quick start guide on lua for c/c++ programmers

Extrait du cours a quick start guide on lua for c/c++ programmers

Preface
The guide is for experienced C/C++ programmers, who want to understand Lua, or quickly grasp the key points and conventional programming patterns of Lua. Therefore it’s not intended to teach its audiences those as obvious as the grammars for if-conditions and function definitions, and those concepts as basic as  Variable and Function common in any modern languages. Instead, the guide is only intended to tell you what distinctive characters Lua has against C/C++, and what widely different programming methodologies Lua brings to us. Do not look down them upon: they are to potentially convert you of your conventional programming world view of C/C++.
Rudimentary Topics
Data Types
Function
Table
Simple Object Implementation
Simple Inheritance
Data Types
8 types:
Number
Numeric value represented in double in Lua standard implementation.
String
A sequence of arbitrary characters(including zero) ending with zero, not equivalent to C string, but indeed its superclass.
Boolean
Logic type with only two values: « true » and « false ».
Function
First-class object in Lua, not equivalent to C function or function pointer; one of the key concepts of Lua.
Table
Heterogeneous hash table; also a key concept of Lua.
Function
function foo(a, b, c)
local sum = a + b
return sum, c  –A function can return multi values.
end
Function(continued)
Function definition
Define a function with key word « function » and end it with « end ».
Returning multi values from a function
return a, b, c, …
Parallel assignment
a, b = c, d
Local variable
Variable defined with key word « local ». A variable becomes global if no
« local » prefix it, even when it’s defined within a function body!
a = { }
b = { x = 1, [« hello, « ] = « world! » }
a.astring = « ni, hao! »
a[1] = 100
a[« a table »] = b
 Table
output:
1         =>      100
a table =>      table: 003D7238
astring =>      ni, hao!
function:
003DBCE0      =>      function:
003DBD00
—————————hello,
=>      world!
x
=>      1
………

Si le lien ne fonctionne pas correctement, veuillez nous contacter (mentionner le lien dans votre message)
Cours a quick start guide on lua for c/c++ programmers (148 KO) (Cours PDF)
Guide on lua

Télécharger aussi :

Laisser un commentaire

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