文章归档友情连接照片地图

Lua学习笔记

分类:Lua编程  作者:rming  时间:2014-06-02

#LUA读书笔记

  1. 在Lua中,一切都是变量,除了关键字。请记住这句话。
  2. 语句块在C++中是用"{"和"}"括起来的,在Lua中,它是用do 和 end 括起来的
  3. 请先记住,在Lua中,只有false和nil才计算为false,其它任何数据都计算为true,0也是true!的
  4. 赋值语句在Lua被强化了。它可以同时给多个变量赋值。例如:a,b,c,d=1,2,3,4甚至是:a,b=b,a -- 多么方便的交换变量功能啊。

#What's in a name?

"Lua" (pronounced LOO-ah) means "Moon" in Portuguese. As such, it is neither an acronym nor an abbreviation, but a noun. More specifically, "Lua" is a name, the name of the Earth's moon and the name of the language. Like most names, it should be written in lower case with an initial capital, that is, "Lua". Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!

#Why choose Lua?

  • Lua is a proven, robust language
  • Lua is fast
  • Lua is portable
  • Lua is embeddable
  • Lua is powerful (but simple)
  • Lua is small

$ LuaJIT-Lua即时编译器

JIT编译器,英文写作Just-In-Time Compiler,中文意思是即时编译器。
JIT编译器能够将MSIL编译成为各种不同的机器代码,以适应对应的系统平台,最终使得程序在目标系统中得到顺利地运行。

安装实例: ubuntu 14.04/gcc 4.8.2

#下载源码

LuaJIT下载地址

$ cd ~
$ wget http://luajit.org/download/LuaJIT-2.0.3.tar.gz
$ tar zxvf LuaJIT-2.0.3.tar.gz
$ cd LuaJIT-2.0.3

#INSTALL

LuaJIT安装文档

$ sudo make && sudo make install
...
ln -sf luajit-2.0.3 /usr/local/bin/luajit
==== Successfully installed LuaJIT 2.0.3 to /usr/local ====

$ luajit
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
>


提交评论