Luan.load()

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Luan.load()

fschmidt
Administrator
http://luan.luanhost.com/manual.html#Luan.load

The current signature is:

Luan.load (text, [source_name [, env [, allow_expression]]])

I want to change it to:

Luan.load (text, [source_name [, allow_expression [, env]]])

This would make it closer to Lua:

https://www.lua.org/manual/5.3/manual.html#pdf-load

Okay?
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Luan.load()

fschmidt
Administrator
Or another option would be to have 2 different methods:

Luan.load (text, [source_name [, env]])
Luan.load_expression (text, [source_name [, env]])

This may be cleaner and would allow:
local x = '{a=1;b=2;c=3}'
local mytable = Luan.load_expression(x)()
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Luan.load()

fschmidt
Administrator
In reply to this post by fschmidt
One more option is to get rid of the expression idea and just have:

Luan.load (text, [source_name [, env]])

Then you would do:
local x = '{a=1;b=2;c=3}'
local mytable = Luan.load("return "..x)()
I think this is my preference.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Luan.load()

Hugo <Nabble>
Administrator
We discussed this. We can do this with Luan.eval().
Reply | Threaded
Open this post in threaded view
|

Re: Luan.load()

fschmidt
Administrator
done.  Here is the implementation of Luan.eval():
function M.eval(s,source_name)
	return M.load( "return "..s, source_name or "eval" )()
end
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Luan.load()

Hugo <Nabble>
Administrator
It looks good, thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Luan.load()

fschmidt
Administrator
closing
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture