R object identity
identity, object, r
Solution
UPDATE: A more robust and faster implementation of `address(x)` (not using `.Internal(inspect(x))`) was added to data.table v1.8.9. From NEWS :
New function `address()` returns the address in RAM of its argument. Sometimes useful in determining whether a value has been copied or not by R, programatically.
There's probably a neater way but this seems to work.
address = function(x) substring(capture.output(.Internal(inspect(x)))[1],2,17)
x = 1
y = 1
z = x
identical(x,y)
# [1] TRUE
identical(x,z)
# [1] TRUE
address(x)==address(y)
# [1] FALSE
address(x)==address(z)
# [1] TRUE
You could modify it to work on 32bit by changing `17` to `9`.
Problem
is there a way to test whether two objects are identical in the R language? For clarity: I do not mean identical in the sense of the `identical` function, which compares objects based on certain properties like numerical values or logical values etc. I am really interested in object identity, which for example could be tested using the `is` operator in the Python language.