What’s the idiomatic and DRY way of writing something like this:
function foo(async::Bool) if async @async dostuff() else dostuff() end
The problem here is that the code is not DRY, I have to call
dostuff() twice (and the problem is, in general, there will be more logic duplicated).
I tried referencing the macro but it errors out (syntax error) - in the line of:
function foo(async::Bool) doasync = async ? @async : @sync # errors out doasync dostuff() end
Any idea? It’s a pretty common pattern for me, for example, I have many instances where if a debug flag is set, certain computations are prefixed with
@time. Now it’s the same non-DRY mess.