logoalt Hacker News

kazinatortoday at 4:52 PM1 replyview on HN

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.

Replies

deathanatostoday at 6:52 PM

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.