08 setembro, 2021
f1 <- function(x) { print(.Internal(inspect(x))) x } f2 <- function(x) { print(.Internal(inspect(x))) x[1] <- 10 print(.Internal(inspect(x))) x }
# Caso 1 a <- c(1, 2, 3) .Internal(inspect(a)) ## @0x000000000a426578 14 REALSXP g0c3 [REF(1)] (len=3, tl=0) 1,2,3 k1 <- f1(a) ## @0x000000000a426578 14 REALSXP g0c3 [REF(2)] (len=3, tl=0) 1,2,3 ## [1] 1 2 3 .Internal(inspect(k1)) ## @0x000000000a426578 14 REALSXP g0c3 [REF(2)] (len=3, tl=0) 1,2,3 # Caso 2 a <- c(1, 2, 3) .Internal(inspect(a)) ## @0x000000000a426398 14 REALSXP g0c3 [REF(1)] (len=3, tl=0) 1,2,3 k2 <- f2(a) ## @0x000000000a426398 14 REALSXP g0c3 [REF(2)] (len=3, tl=0) 1,2,3 ## [1] 1 2 3 ## @0x000000000a426258 14 REALSXP g0c3 [REF(1)] (len=3, tl=0) 10,2,3 ## [1] 10 2 3 .Internal(inspect(k2)) ## @0x000000000a426258 14 REALSXP g0c3 [REF(1)] (len=3, tl=0) 10,2,3