Lua Types, Tables and Functions

Cours Lua Types, Tables and Functions, tutoriel & guide de travaux pratiques en pdf.

Lua Overview

Lua is a powerful, fast, lightweight, embeddable scripting language, often used for configuration, very popular in the gaming communities.
Things I would say about Lua In an Elevator With a Geek… • Simple, Ruby-like syntax • Designed to be embedded • Stack-based interface to the host • Compiles cleanly nearly everywhere – ANSI-C • Tables are the key to Lua’s power • First class functions allow closures, coroutines • The only real oddity is that indices start at 1
or, you can read the poster…
Lua Types
• nil • boolean • number • string
• table • function • userdata • thread
• Variables are typeless • Only values have types • All values are ‘first class values’ • Numbers are always floats
Tables
“Sets” and “Arrays” are both implemented via Tables. Most similar to Ruby Hashes, but fields addressable as methods on the table. t = {} t = { a=7;b=print;c=”yahtzee” } t.a — 7 t[‘c’] — “yahtzee” print(type(t.b)) — “function”
Functions
• Functions are first-class • Can be anonymous • Can take a variable number of parameters

LIRE AUSSI :  ngx_lua overview

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

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