class Main {
static function main() {
var m = new Main();
log(m.foo); // ok
m.foo = null;
log(m.foo); // fail
}
function new() {}
dynamic function foo():String
return 'foo';
static function log(f:()->String)
if(f != null) trace(f());
}
Haxe generated:
var m = new Main();
Main.log($bind(m,m.foo));
m.foo = null;
Main.log($bind(m,m.foo));
genes:
var m = new Main();
Main.log(m.foo.bind(m));
m.foo = null;
Main.log(m.foo.bind(m));
and obviously m.foo.bind will fail when m.foo is null
Haxe generated:
genes:
and obviously
m.foo.bind
will fail whenm.foo
is null