From a70a8c3dde884123248fae63060f2ec2d08255d4 Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Tue, 23 Jul 2019 16:40:33 +0100 Subject: [PATCH] Added point about line terminators --- readthedocs/lua-introduction.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/readthedocs/lua-introduction.rst b/readthedocs/lua-introduction.rst index ccf5135..849b751 100644 --- a/readthedocs/lua-introduction.rst +++ b/readthedocs/lua-introduction.rst @@ -11,6 +11,7 @@ Key Features of Lua * Lua versions matter * Lua is dynamically typed like Python * By default variables in Lua are global unless declared local +* Lua has no line terminators * There is a single complex / aggregate type called a 'table', which combines hash table/map and array features * Functions in Lua are values stored in variables; in particular functions do not have names * Globals in Lua are just values stored in a special Lua table @@ -83,6 +84,19 @@ There are some exceptions to the rule: * the iterator variables declared in a ``for`` loop are implicitly local. * function parameters are local to the function +Lua has no line terminators +=========================== +Strictly speaking you can terminate Lua statements using ``;``. However it is not necessary except in some cases to avoid ambiguity. + +This design has some consequences that took me by surprise:: + + local x y = 5 + +Above creates a local variable ``x`` and sets a global ``y`` to ``5``. Because it actually parses as:: + + local x + y = 5 + The 'table' type ================ Lua's only complex / aggregate data type is a table. Tables are used for many things in Lua, even internally within Lua.