1
0
Fork 0

add thisfunc() for reliable recursion

This commit is contained in:
mfranz 2008-07-22 19:03:25 +00:00
parent cb3150b915
commit b9e7bb1b4b

View file

@ -99,6 +99,14 @@ var defined = func(sym) {
} }
##
# Returns reference to calling function. This allows a function to
# reliably call itself from a closure, rather than the global function
# with the same name.
#
var thisfunc = func caller(1)[1];
## ##
# Print log messages in appropriate --log-level. # Print log messages in appropriate --log-level.
# Usage: printlog("warn", "..."); # Usage: printlog("warn", "...");
@ -109,7 +117,7 @@ __ = {};
__.dbg_types = { none:0, bulk:1, debug:2, info:3, warn:4, alert:5 }; __.dbg_types = { none:0, bulk:1, debug:2, info:3, warn:4, alert:5 };
__.log_level = __.dbg_types[getprop("/sim/logging/priority")]; __.log_level = __.dbg_types[getprop("/sim/logging/priority")];
var printlog = func(level, args...) { var printlog = func(level, args...) {
if(__.dbg_types[level] >= __.log_level) { call(print, args); } if(__.dbg_types[level] >= __.log_level) call(print, args);
} }