lua-users home
lua-l archive

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


I'm using Lua to write game engine components, and this is *exactly* this would really help me out a lot. I posted not so long ago about wanting to intrinisically return a value from a script, and this
would do just that (assuming that it worked from the C API).

Jason
379



Eric Ries wrote:

This is only tangentially related to this discussion, but I feel it may
affect the Lua-as-language vs Lua-as-configfile line up.

I am curious if it would be worthwhile to implement a perl-style eval() for
executing lua code. Lua's dostring() is very close, but eval() has the added
advantage of automatically returning the last statement executed. So for
instance eval( "10" ) is equivalent to dostring( "return 10" )

I have found this behavior to be especially useful in both scripting
language and config file contexts. In fact, I think we could probably expand
upon it, perhaps deciding on some additional behaviors that perl does not
have. In particular, I think it might be handy for eval() to return a table
of all of the expressions evaluated during the call. So the following two
would be equivalent

foo = eval( "function foo() ... end { a = 1, b = 2 }" )

foo = dostring( "return { function foo() ... end, { ... } }" )

Any thoughts?