[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Undocumented/Buggy Behavior with Function Definitions
- From: RJ Russell <russellsprouts2@...>
- Date: Sat, 31 Oct 2009 19:06:15 -0700
The Manual says that:
function f () body end
is translated to:
f=function() body end,
However, this code doesn't seem to work:
-----------------------------------------------------------------
do
local cdoc
local docs
local function newindex(G,k,v)
docs[k]=cdoc
rawset(G,k,v)
setmetatable(_G,nil)
end
function adddoc(s)
cdoc=s
setmetatable(_G,{__newindex=newindex})
end
end
adddoc[[-----------------------
-- Some function doc
-- that has info in it
--Blah foo bar baz
----------------------------------]]
function Foo(arg1)
doStuff()
end
----------------------------------------------------------------
Apparently function definitions like that bypass the __newindex
metamethod in the globals table. Why is this not stated?