lua-users home
lua-l archive

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


On 11/11/12, spir <denis.spir@gmail.com> wrote:
>     __ENV = require "stdkit"

BTW, IMHO, "with" statement from Pascal is highly desirable in Lua:
with <list_of_tables> do <statements> end

Unfortunately, the same functionality cannot be achieved using _ENV.

-- module mod.lua
return {a = 'from module', print = print}

-- program using _ENV
local a = 'local var'
do
  local _ENV = require 'mod'
  print(a)  --> local var
end

-- program using "with"
local a = 'local var'
with require 'mod' do
  print(a)  --> from module
end