This is great, I completely missed default values (assumed haxe would present these in the function body instead). Since we have emitValue for this purpose I used that instead.
The difference is in expressions that wouldn't be a value in javascript. For example:
var value = if (true) 1 else 2;
Which is valid haxe code but the if expression must be emitted as value.
// with emitExpr
var value = if (true) 1 else 2; // invalid js
// with emitValue
var value = (true) ? 1 : 2; // valid js
Because default parameters are expected to be constant this works with emitExpr as well. But haxe could eventually support other expressions too. Since we're outputting as a value the Const(_) check can go too.
This is great, I completely missed default values (assumed haxe would present these in the function body instead). Since we have
emitValue
for this purpose I used that instead. The difference is in expressions that wouldn't be a value in javascript. For example:Which is valid haxe code but the if expression must be emitted as value.
Because default parameters are expected to be constant this works with
emitExpr
as well. But haxe could eventually support other expressions too. Since we're outputting as a value theConst(_)
check can go too.