Something(a, b) not shortcutting

Charlie_He
Tue, 20 Aug 2019 08:04:34 +0000
Performance

Assuming we have:

function do_work(x)
    sleep(2)
    x
end

It turns out something(Some(2), do_work(3)) still invoke do_work, which returns 2 seconds later.
It would be better to define it as a macro, which retains the arguments as AST and only evaluate them when necessary.

5 posts - 3 participants