1
0
Fork 0

remove debug.exit(); add debug.isnan()

- exit was only justified at times where fgcommand() needed an explicit
  node statement, which made using it a bit clumsy. Nowadays that's only
  fgcommand("exit"), which is as good as debug.exit() was.
- isnan() is really only for debugging and, thus, not in the global
  namespace. Nasal code should never generate NaNs (though it's easy:
  var nan = 1/0; There! :-), and NaNs imported from the C++ side (tied
  properties!) should get fixed there. IOW: routine checks for nan in
  Nasal can only be temporary hacks/debugging measures.
This commit is contained in:
mfranz 2009-02-06 14:41:13 +00:00
parent 1d50d3c086
commit 1d783e03bb

View file

@ -21,8 +21,6 @@
# (similar to props.dump()), otherwise
# use space indentation
#
# debug.exit() ... exits fgfs
#
# debug.bt() ... abbreviation for debug.backtrace()
#
# debug.string(<variable>) ... returns contents of variable as string
@ -30,6 +28,9 @@
# <verb>ose is by default 1, and suppressed the
# node's refcounter if 0.
#
# debug.isnan() returns 1 if argument is an invalid number (NaN),
# 0 if it's a valid number, and nil in all other cases
#
# debug.benchmark(<label:string>, <func> [, <repeat:int>])
# ... runs function <repeat> times (default: 1)
# and prints execution time in seconds,
@ -185,10 +186,9 @@ var _dump_key = func(s) {
return _dump_string(s);
if (!globals.string.isalpha(s[0]) and s[0] != `_`)
return _dump_string(s);
for (var i = 1; i < size(s); i += 1) {
for (var i = 1; i < size(s); i += 1)
if (!globals.string.isalnum(s[i]) and s[i] != `_`)
return _dump_string(s);
}
_dump_var(s);
}
@ -296,9 +296,6 @@ var benchmark = func(label, fn, repeat = 1) {
}
var exit = func fgcommand("exit");
##
# print error vector as set by call(). By using call() one can execute
# code that catches "exceptions" (by a die() call or errors). The Nasal
@ -318,3 +315,6 @@ var printerror = func(err) {
}
var isnan = (func { var nan = 1 / 0; func(d) num(d) == nil ? nil : d == nan; })();