Memory address of a set, array, string,

These functions are typically only used when calling foreign functions, e.g. C, Fortran, etc. Technically a julia Set{Int} is an immutable struct containing a Dict{Int, Nothing}, and immutable structs don’t have a memory address. They can live on the stack, in registers or in memory, as the compiler sees fit. You should use Ref(...) to obtain a reference to a julia object.

julia> s = Set([1,2,3])
Set{Int64} with 3 elements:
  2
  3
  1

julia> s.dict
Dict{Int64, Nothing} with 3 entries:
  2 => nothing
  3 => nothing
  1 => nothing

julia> s.dict = Dict([2=>nothing])
ERROR: setfield!: immutable struct of type Set cannot be changed
Stacktrace:
...

julia> s.dict[4] = nothing
julia> s
Set{Int64} with 4 elements:
  4
  2
  3
  1

3 Likes