← Back to context

Comment by kazinator

2 hours ago

In 1990s C++ we did:

  void foo::method(const &smart_ptr<thing> x) { ... }

The smart pointer passed reference isn't copy-constructed and so no refcount is bumped. It has a scoped lifetime. The calling function owns a reference (baseline correctness assumption or else we are screwed). That caller is suspended while the callee executes.

It's still done. It's not uncommon to see that in Rust:

  fn foo(x: &Arc<T>)

…quite literally borrows the count in the refcount-ed thing.

I think you can find similar things in CPython, on the C side of things.