Sommaire: Erlang And Lua
I Embedded Scripting Languages
II Overview of the Lua Language
III Using Lua in Erlang
IV Erlmon, a system monitoring tool that uses Lua
Extrait du cours erlang And Lua
I : Embedded Scripting Languages
Language…………Description
Javascript………..Ubiquitous
Reia…………………Ruby+Python/Erlang
Lua………………….Fast, lightweight; popular with gamers
flowchart
II : 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
Tables and Functions Together
m = create_message(“chad@erlanginside.com”,
“chad@rubyrescue.com”,“you have too many emails”)
> m.send() Sending from chad@erlanginside.com to chad@rubyrescue.com
……….
Télécharger cours: Erlang And Lua (1.61 MO) (Cours PDF)