lua: Learning Official Doc notes

Posted 三叁

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lua: Learning Official Doc notes相关的知识,希望对你有一定的参考价值。

dynamically typed vars:

basic types: nil, boolean, number, string, function, userdata, thread & table.

where nil has only one value, is mainly to differ from other types. absense of useful info

bool: false & true. so false & nil are both make a conditional false

number: int & floating point, 2 subtypes, rules to when to use which. also converting automatically, standard lua use 64-bit num. but can re-compile lua to use 32bit. (see luaconf.h

string: immutable sequence of bytes, containing all info in 8-bit value. encoding-agnostic (nice !

 

calling functions written in lua/c. 

 

userdata: store any c data. raw memory. 2 kinds of userdata: full userdata: object; light userdata: pointer value. this type of data has no predefined ops, only to assign or identity test. It cannot be created or modifiied in lua. only through C api. guarentees the integrity. But using metatables, user can define ops for full userdata.

 

thread: represents independent threads of execution and used to implement coroutines. its not same as os‘s threads... coroutines are supported on all systems. even on no thread systems..

 

table: assoc. arrays. map? yes. with tables, arrays can be indexed through values other than numbers, but not nil or NaN. where NaN is actually number typed and to represent INF. but the key value can be anything except nil.. pathetic.. and conversely.. very odd.. any key not belonging to a table has an associated value nil. a.name is equal to a["name"]. -- syntax sugar

 

sequence 

 

concept: equal without metamethods.. a.i, a.j refer to the same obj iff. i, j EWM. however, a.2 and a.2.0 refer to the same obj.. because float value which is actually a int will be automatically convert to the int.. so a.2.0 is actually a.2 .. table fields can be of any type.. including functions, tables can carry methods

 

tables, functions, threads, full userdata values are objs and refer to the address where locates. functions manipulate these refs only return the refer to these values, not modifying

 

function: type(), this returns a string describing the type of value..

 

以上是关于lua: Learning Official Doc notes的主要内容,如果未能解决你的问题,请参考以下文章

一个LUA配置检测工具

lua中的泛型for用法: for i, v in talbe do....end

Lua学习十----------Lua数组

How do you explain Machine Learning and Data Mining to non Computer Science people?

为你读诗 No.4 第四期 | O Amor do Sol pela Lua 太阳对月亮的爱

05 Lua 控制结构