[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: scope, design patterns?
- From: Alexander Gladysh <agladysh@...>
- Date: Tue, 28 Dec 2010 06:41:23 +0300
On Tue, Dec 28, 2010 at 06:33, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Tue, Dec 28, 2010 at 06:16, Patrick Mc(avery
> <spell_gooder_now@spellingbeewinnars.org> wrote:
> Any known symbols used in handler are imported in the generated code
> as needed, if anything that is not known is met, generation fails.
I think that a synthetic example is in order:
api:call "foo"
{
handler = function(context)
assert(write_file("/tmp/out.txt", "42"))
end;
}
Translates to
local assert = assert
local write_file = import 'lua-aplicado/filesystem.lua' { 'write_file' }
local handler = function(context)
assert(write_file("/tmp/out.txt", "42"))
end
return
{
handler = handler;
}
That import() is a simple wrapper around loadfile() or require():
https://github.com/lua-nucleo/lua-nucleo/blob/master/lua-nucleo/import.lua
https://github.com/lua-nucleo/lua-nucleo/blob/master/lua-nucleo/import_as_require.lua
Alexander.
- References:
- scope, design patterns?, Patrick Mc(avery
- Re: scope, design patterns?, Tomas Guisasola Gorham
- Re: scope, design patterns?, Patrick Mc(avery
- Re: scope, design patterns?, Alexander Gladysh
- Re: scope, design patterns?, Patrick Mc(avery
- Re: scope, design patterns?, Alexander Gladysh