Reflection/Get source: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
m →‎{{header|Wren}}: Minor correction to preamble.
→‎{{header|Lua}}: added Lua solution
Line 306: Line 306:
put getGlobalFunctionCode(func)
put getGlobalFunctionCode(func)
-- script text is printed...</lang>
-- script text is printed...</lang>

=={{header|Lua}}==
Introspective capabilities are provided by the debug library..
<lang lua>debug = require("debug")
function foo(bar)
info = debug.getinfo(1)
for k,v in pairs(info) do print(k,v) end
end
foo()</lang>
{{out}}
<pre>linedefined 2
func function: 0000000000d8d670
currentline 3
source @reflection.lua
lastlinedefined 5
short_src reflection.lua
what Lua
namewhat global
nparams 0
isvararg false
name foo
istailcall false
nups 1</pre>


=={{header|Nanoquery}}==
=={{header|Nanoquery}}==