haxe.Stack for PHP

in

Starting from haXe 2.04 the PHP generator supports the -debug switch. The implementation is almost identical to the haXe/JS one where the function calls are stored in a stack. You can see it working when you have an uncaught exception or using the haxe.Stack methods as in the following example:

import haxe.Stack;
class Test {
  static function main() {
    var f = function() { ref(); };
    f();
  }
	
  static function ref() {
    throw "error";
  }
}

The output will be:

uncaught exception: error

Called from Test::ref
Called from Test::main@4
Called from Test::main

Note that @4 means that a local function is involved.
You can obtain the same output without generating an exception replacing throw "error" with:

trace(Stack.toString(Stack.callStack()));

Is it appropriate to remove the -debug switch when compiling for deployment since it adds extra code to your output.

Related Project(s): 
haXe/PHP