Refer to Julia doc:
In Julia, all arguments to functions are passed by reference.
When I get the memory address of a Float64 argument from an anonymous function it looks right. but it's not true for a named function.
test = function (a::Float64)
println(pointer_from_objref(a));
end
# => (anonymous function)
function test1(a::Float64)
println(pointer_from_objref(a));
end
# => test1 (generic function with 1 method)
value=0.0;
println(pointer_from_objref(value))
# => Ptr{Void} @0x00007fe797c5c020
test(value)
# => Ptr{Void} @0x00007fe797c5c020
test1(value)
# => Ptr{Void} @0x00007fe799e83960
as @Gnimuc mentioned, there is another paragraph from Julia-Lang Doc that explains Argument Passing Behavior
Julia function arguments follow a convention sometimes called “pass-by-sharing”, which means that values are not copied when they are passed to functions. Function arguments themselves act as new variable bindings (new locations that can refer to values), but the values they refer to are identical to the passed values.
Is there any relation between this “pass-by-sharing” behavior and the above code?
location
mean here. – Gnimuc