[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules and require all
- From: Egor Skriptunoff <egor.skriptunoff@...>
- Date: Mon, 12 Nov 2012 18:55:56 +0300
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