Overriding methods with closures?

Hi and welcome!

The definition of add as a local name shadows all outer definitions.
To access any global identifier within a scope where that name is already taken, you can prepend them with the module name.
In your case, assuming you work in module Main:

function add(x, y) x + y end
function test()
    add(y) = Main.add(1, y)
    add(2)
end
test()
2 Likes