lua-users home
lua-l archive

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

On 01/12/14 12:50 AM, Tim Hill wrote:
On Nov 30, 2014, at 4:58 PM, Thiago L. <> wrote:

function() return ("").sub end -- Issue number 1: How am I supposed to get an environment out of this thing from the string metatable? (seeing as there's no _ENV and no way to access the env of the scope that created this function)
Not sure I understand this issue. The function will of course use whatever environment that was appropriate to it (in this case, the environment of the enclosing function). What do you want it to do?
There is no environment. Feel free to inspect it with debug.*.
  local type = type
  local _ENV = {print=print, tostring = function(i) if type(i) == "string" then return ("%q"):format(i) end return ("%s"):format(i) end}
  print("Issue number 2: Uh oh! This doesn't get serialized!")

Again, what is the issue here? What problem are you trying to address?
print() isn't calling my environment's tostring().


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.