lua-users home
lua-l archive

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



On 19/02/15 09:39 AM, Roberto Ierusalimschy wrote:
local b = (loadstring or load)("function a()\n  print(1)\n
print(2)\nend\n return a") -- added "return a"
local d = b()
Right, this works, but this is not quite what I'm looking for; this is why
I added "without executing the fragment". The general task is to figure out
the code lines in a file (those that may have breakpoints) without
executing it. I thought that's what activelines gives me, but it doesn't
seem to be the case (or maybe I'm not using it the right way), hence the
question.
Functions in a chunk are only created when you execute the chunk. So,
while you do not run the fragment, there is no "function a" to be talked
about.

-- Roberto

Could this be solved by adding something like debug.getclosure(chunk, cl_id)? (and functions to instantiate such a closure?)

I mean, string.dump DOES dump inner closures, doesn't it?

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.