! This somewhat obfuscated function will print anything. ! It handles strings, functions (with optional arguments), objects, ! object properties (with optional arguments), and dictionary words. ! It does *not* handle plain integers, but you can use ! DecimalNumber or EnglishNumber to handle that case. ! ! Calling: Is equivalent to: ! ------- ---------------- ! PrintAnything() ! PrintAnything(0) ! PrintAnything("string"); print (string) "string"; ! PrintAnything('word') print (address) 'word'; ! PrintAnything(obj) print (name) obj; ! PrintAnything(obj, prop) obj.prop(); ! PrintAnything(obj, prop, args...) obj.prop(args...); ! PrintAnything(func) func(); ! PrintAnything(func, args...) func(args...); [ PrintAnything _vararg_count obj mclass; if (_vararg_count == 0) return; @copy sp obj; _vararg_count--; if (obj == 0) return; if (obj->0 == $60) { ! Dictionary word. Metaclass() can't catch this case, so we do ! it manually. print (address) obj; return; } mclass = metaclass(obj); switch (mclass) { nothing: return; String: print (string) obj; return; Routine: ! Call the function with all the arguments which are already ! on the stack. @call obj _vararg_count 0; return; Object: if (_vararg_count == 0) { print (name) obj; } else { ! Push the object back onto the stack, and call the ! veneer routine that handles obj.prop() calls. @copy obj sp; _vararg_count++; @call CA__Pr _vararg_count 0; } return; } ];