14.20 R6 makes it harder to reason about code

  • Reference semantics makes code harder to reason about.
x <- list(a = 1)
y <- list(b = 2)

# Here we know the final line only modifies z
z <- f(x, y)

# vs.

x <- List$new(a = 1)
y <- List$new(b = 2)

# If x or y is a method, we don't know if it modifies
# something other than z. Is this a limitation of
# abstraction?
z <- f(x, y)
  • I understand the basics, but not necessarily the tradeoffs.
    • Anyone care to fill me in?
    • Is this a limitation of abstraction?