That’s a separate issue. LegibleLambdas will suffer from that issue to the same extent that regular illegible closures do. Here’s an example:
julia> using LegibleLambdas
julia> f(x) = y -> begin
x = x + 1.0
x + y
end
f (generic function with 1 method)
julia> g(x) = @λ y -> begin
x = x + 1.0
x + y
end
g (generic function with 1 method)
julia> let x = Ref(1), y = Ref(2)
@btime f($x[])($y[])
@btime g($x[])($y[])
end
48.969 ns (3 allocations: 48 bytes)
48.582 ns (3 allocations: 48 bytes)
4.0
One thing that’s nice though about LegibleLambdas is that it can help diagnose this problem:
julia> g(1)
(y -> begin
Core.Box(1) = Core.Box(1) + 1.0
Core.Box(1) + y
end)
Though, the ‘legible’ printing leaves something to be desired here. I basically just walked through the syntax tree and replaced x with 1, so in the presence of rebindings and such, it’s kinda nonsense. Where is says Core.Box(1), it’s really Core.Box(x).