|
|
|
|
|
by rbehrends
2803 days ago
|
|
> This is a thing people say, but I think it's misleading. Reference counting can increase the lifetime of an object, but borrowing cannot. I've seen this really trip up beginners. "With a maximum reference count of 1." As the reference count becomes 1 upon object creation, it cannot really be increased further. Hence, only operations that keep the (virtual) reference count at 1 or reduce it to 0 are allowed. My point here is that you inherently cannot do things where you cannot prove that this virtual reference count can be capped at 1. |
|
It also only refers to ownership, not borrowing, and both are equally important.
Beyond that, what I'm saying is something more meta: It doesn't really matter if this analogy is spot-on or not; it's got enough wiggle room in it that I've seen it trip up beginners. Maybe that's because they misunderstand the analogy, but given that its point is to convey understanding, that means that it isn't a great analogy, in my experience. YMMV.
1: directly, of course; this also depends on the language.