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..
special thing in table is the metatable, its inside the original table, besides the key and value, as another table. __index, __newindex, __call, __tostring. Where __index influence the behavior when referencing data not inside the main table, __newindex influences assignments of the keys, __call influences behavior when using tablename as methods, like table(), __tostring influences when print(table).. behavior.
lua: Learning Official Doc notes的更多相关文章
- Machine Learning Algorithms Study Notes(3)--Learning Theory
Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 22 ...
- Machine Learning Algorithms Study Notes(2)--Supervised Learning
Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 22 ...
- Machine Learning Algorithms Study Notes(1)--Introduction
Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 目 录 1 Introduction 1 1.1 ...
- Machine Learning Algorithms Study Notes(6)—遗忘的数学知识
机器学习中遗忘的数学知识 最大似然估计( Maximum likelihood ) 最大似然估计,也称为最大概似估计,是一种统计方法,它用来求一个样本集的相关概率密度函数的参数.这个方法最早是遗传学家 ...
- Machine Learning Algorithms Study Notes(5)—Reinforcement Learning
Reinforcement Learning 对于控制决策问题的解决思路:设计一个回报函数(reward function),如果learning agent(如上面的四足机器人.象棋AI程序)在决定 ...
- Machine Learning Algorithms Study Notes(4)—无监督学习(unsupervised learning)
1 Unsupervised Learning 1.1 k-means clustering algorithm 1.1.1 算法思想 1.1.2 k-means的不足之处 1 ...
- Deep Learning Workbench Installation Notes
1. ROS Indigo (30 min) Just flow ROSWiki: http://wiki.ros.org/indigo/Installation/Ubuntu NOW simply ...
- <YaRN><Official doc><RM REST API's>
Overview ... YARN Architecture The fundamental idea of YARN is to split up the functionalities of re ...
- learning ext2 filesystem notes
reference: http://e2fsprogs.sourceforge.net/ext2intro.html reference: http://www.nongnu.org/ext2-do ...
随机推荐
- Openjudge-NOI题库-对齐输出
题目描述 Description 读入三个整数,按每个整数占8个字符的宽度,右对齐输出它们. 输入输出格式 Input/output 输入格式: 只有一行,包含三个整数,整数之间以一个空格分开. ...
- UltimateDefrag磁盘碎片整理软件 v3.0.100.19汉化版
软件名称:UltimateDefrag磁盘碎片整理软件 v3.0.100.19汉化版软件类别:汉化软件运行环境:Windows软件语言:简体中文授权方式:免费版软件大小:3.25 MB软件等级:整理时 ...
- typeof使用笔记
typeof操作符返回一个字符串,表示未经计算的操作数的类型 以下是可能值的列表 类型 结果 Undefined "undefined" Null "nu ...
- Swift2.3适配Swift3.0时出现的各种问题
昨晚上一波手贱把我的小5s升到iOS10.如此配套的话,Xcode7.3升级Xcode8.1看来也是势在必行了.公司程序是Swift2.3的,出于对苹果的恐惧迟迟不敢升级.但丑媳妇儿总要见公婆,借这个 ...
- directive(指令里的)的compile,pre-link,post-link,link,transclude
The nitty-gritty of compile and link functions inside AngularJS directives The nitty-gritty of comp ...
- linux(centos7)下SVN服务器如何搭建
linux(centos)下SVN服务器如何搭建?说到SVN服务器,想必大家都知道,可以是在LINUX下如何搭建SVN服务器呢?那么今天给大家分享一下linux(centos)搭建SVN服务器的思路! ...
- Excel 文件转 JSON格式对象
将导入的如图所示格式的城乡区划代码的excel文件整理成json格式的对象储存在js文件中: var PROJECTDISTRICTDATA=[ { "name" ...
- Jquery 返回顶部
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- 使用MyBatis3时 selectOne 方法返回null的问题记录
不多废话,直接上干货. mapper配置: <resultMap type="User" id="usermap"> <result colu ...
- 数据库及SQL优化
一.数据库结构的设计 如果不能设计一个合理的数据库模型,不仅会增加客户端和服务器段程序的编程和维护的难度,而且将会影响系统实际运行的性能.所以,在一个系统开始实施之前,完备的数据库模型的设计是必须的. ...