[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Global Table Customization
- From: "Mike Roberts" <miker@...>
- Date: Mon, 6 Aug 2001 17:52:10 -0700
is there a reason why the default tag method for the "getglobal" event
couldn't be (*emphasis* added):
function getglobal (varname)
-- access the table of globals
local value = *gettable*(globals(), varname)
local tm = gettagmethod(tag(value), "getglobal")
if not tm then
return value
else
return tm(varname, value)
end
end
instead of (taken from the 4.0 manual):
function getglobal (varname)
-- access the table of globals
local value = *rawget*(globals(), varname)
local tm = gettagmethod(tag(value), "getglobal")
if not tm then
return value
else
return tm(varname, value)
end
end
This would allow one to use a globals table with a tag generated by newtag()
to customize the way global variable accesses are handled.
For example, if a script is looking for a variable that isn't in the globals
table, an alternative action could be taken by changing the tag of the
globals table and writing a tag method the "index" event.
I personally would like to search other tables if a global cannot be found
before returning nil. What I have described would make it possible.
--
Mike Roberts (zoarre)
Server Developer
Artifact Entertainment, Inc.
email <miker@artifact-entertainment.com>
web <http://www.artifact-entertainment.com>
phone 480-218-1223 ext 309
"C++: an octopus made by nailing extra legs onto a dog." -unknown
begin 666 Mike Roberts.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..E)O8F5R=',[36EK90T*1DXZ
M36EK92!2;V)E<G1S#0I/4D<Z07)T:69A8W0@16YT97)T86EN;65N="P@26YC
M+@T*5$E43$4Z3&5A9"!397)V97(@1&5V96QO<&5R#0I414P[5T]22SM63TE#
M13HH-#@P*2 R,3@M,3(R,R!X,C(R#0I414P[5T]22SM&05@Z*#0X,"D@,C$X
M+3$R,C4-"D%$4CM73U)+.CL[-#@T,"!%+B!*87-M:6YE+"!3=&4@,3 R.TUE
M<V$[05H[.#4P,C4[56YI=&5D(%-T871E<R!O9B!!;65R:6-A#0I,04)%3#M7
M3U)+.T5.0T]$24Y'/5%53U1%1"U04DE.5$%"3$4Z-#@T,"!%+B!*87-M:6YE
M+"!3=&4@,3 R/3!$/3!!365S82P@05H@.#4P,C4],$0],$%5;FET960@4W1A
M=&5S(&]F($%M97)I8V$-"D5-04E,.U!2148[24Y415).150Z;6EK97) 87)T
M:69A8W0M96YT97)T86EN;65N="YC;VT-"E)%5CHR,# Q,#<S,50R,#4U,#-:
-#0I%3D0Z5D-!4D0-"@``
`
end