How to detect caller in haxe?
haxe
Solution
Check out PosInfos. You use it like so:
public static function add(a:Int, b:Int, ?pos:PosInfos) {
trace( 'Called from ${pos.className}');
trace( 'Called from ${pos.methodName}');
trace( 'Called from ${pos.fileName}');
trace( 'Called from ${pos.lineNumber}');
return a+b;
}
add( 1, 1 ); // "pos" will automatically be filled in by compiler
Problem
I am setting a property, I need to know who is setting the property value? is this possible in haxe 3? Also, can I know who is calling a function from inside the function itself?