diff --git a/Nasal/debug.nas b/Nasal/debug.nas index 79118b322..dd707fae2 100644 --- a/Nasal/debug.nas +++ b/Nasal/debug.nas @@ -21,8 +21,6 @@ # (similar to props.dump()), otherwise # use space indentation # -# debug.exit() ... exits fgfs -# # debug.bt() ... abbreviation for debug.backtrace() # # debug.string() ... returns contents of variable as string @@ -30,6 +28,9 @@ # 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(, [, ]) # ... runs function 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; })(); + +