lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 04/26/2013 05:48 PM, Doug Currie wrote:
If this is what you want, then the local and global keywords mean the same thing. In expression oriented languages of the ML family, this keyword is called val. It declares a new value in the present scope. So your example becomes:

val myvar

if someboolean then
    myvar = 0
    val g2 = 7
end



Not really:

if true then
 global g = "hello"
 local l = " world"
end

do
  global g
  local l
  print(a) -- prints "hello"
  print(b) -- prints "nil"
end

globals still would have the same semantics as now, you would only declare them before using of them.

--
Thomas