What does this mean when function arguments follow pass-by-sharing?

This refers to Julia, where they mention it in the docs. I noticed that the following happened in my Julia code: I can use the values โ€‹โ€‹of global variables in julia functions without even passing them to the function. Can someone explain what is happening?

0
source share
1 answer

You can read the manual section on "scope . "

Variables act as functions: in

function foo(x) return bar(x)^2 end 

you do not need to pass bar as an argument, define it internally, or declare it a global function. If you wanted to, you could define an inner bar function that locally overrides the global bar function. Variables act similarly: the only time you must explicitly use global is if you change the global variable inside the function.

+1
source

Source: https://habr.com/ru/post/1211474/


All Articles