Hacker News new | ask | show | jobs
by anonymoushn 4720 days ago
I have unfortunately created an annoying case of this, in which a bunch of thunks are put in a list and invoked en masse. If any one of them has a problem, it's a bit of a problem to sort out where it was created. This is exasperated by the fact that functions do not know their own names in Lua.

  Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
  > function f(g) g[1]() end
  > function thisFunctionCrashes() undefinedVariable() end
  > f({thisFunctionCrashes})
  stdin:1: attempt to call global 'undefinedVariable' (a nil value)
  stack traceback:
  	stdin:1: in function '?'
  	stdin:1: in function 'f'
  	stdin:1: in main chunk
  	[C]: ?
In the example, the source line is available, but in the genuine article the thunks are for native functions.