Why are loops faster in functions?

This:

```
a = [1:10_000_000;]
b = zeros(Int64, length(a))
function double!(x, y)
L = length(x)
for i in 1:L
@inbounds y[i] = 2x[i]
end
nothing
end
@time double!(a, b)
```

is much faster than this:

```
@time begin
L = length(a)
for i in 1:L
@inbounds b[i] = 2a[i]
end
end
```