Open kevinresol opened 8 years ago
Is it possible to have a "expression-level" version of tink_await. That I can apply the transformation with a macro call? like so:
var surprise = Await.manuallyTransform({
// my block of code:
@:await string();
});
public macro static function manuallyTransform(expr:Expr) {...}
The above example won't work because even so the outer macro will run first (if I supply a macro call as its parameter)
However, if somehow we can manually execute an expression macro, it may work. https://github.com/HaxeFoundation/haxe/issues/5534
Well, I had a look at that when https://github.com/haxetink/tink_await/issues/10 popped up. Seems like expression macros run when you use Context.typeExpr
on an expression. But it only worked when applied to every expression, not the full body. It also failed multiple times with errors I couldn't catch. Anyway, that's when I gave up :) So we'll have to wait until haxe gives us a proper way to run all expression macros during type building.
The above code won't work because the await macro runs first. After that the typer kicks in and transform the macro call to actual expression. As a result, the generated expression (
@:await string()
) won't get handled by the await macro.So, are there any workarounds for that?