Would you want the REPL to warn against performance traps, at least non-const globals?


const s = 6;
const L = sqrt(11);
r(z) = 1 ./sqrt.(s^2 - (L-z).^2)

That’s part of larger code that was 24x slower than needed, or even more.

I believe it was (before changing at reddit, the only needed change?):

s = 6;
L = sqrt(11);

before, and even a simple demo of the problem would be:

r(a) = a + L
@code_native r(1) # the compiler obviously knows of this global problem.

I would want when defining:

julia> r(a) = a + L
WARNING: that is a speed-trap referring to non-const global L, but it's perfectly ok for interactive calculator use.

What are the worst speed-traps? I could foresee this on by default in the REPL, could be turned off, and maybe degrees a threshold of alerting depending on seriousness.