lua-users home
lua-l archive

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


Am 25.04.2013 05:04 schröbte Owen Shepherd:

Right, but what I was wishing for was the ability to name the parameters
passed to the function returned by load()

An example of the usage of this can be seen along the lines of HTML
event handlers: Imagine an excerpt from a HTML document using Lua
instead of JavaScript:
<button onclick="table.insert(eventLog, ev)">Name</button>
Browsers use the JavaScript functionality to load a fragment of code as
a function with named parameters to inject variables like "ev" into the
function's scope.


What about

loadstring( "local eventLog, ev = ...\n" .. "table.insert(eventLog, ev)" )( eventLog, ev )

?

Philipp