lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


on 5/29/03 10:07 AM, Thatcher Ulrich at tu@tulrich.com wrote:

> void SomeFunction(const SPtr<SomeObject>& ptr)
> {
> // ptr is a reference to an already-existing SPtr<>, so there's
> // no ref inc/dec overhead in the function call binding.
> }
> 
> This is safe and easy, in my experience.  In any case, most
> incremental collectors will need a write-barrier, which in practice is
> probably worse than inc/dec of a ref count.

That's what we did on the last project I worked on as well. It's safe from
the standpoint that you won't get stuck with a stale pointer, but it doesn't
have quite the same semantics since the pointer can be changed and that
change will be visible in the called code. "const" just means that
SomeFunction can't change the pointer.

Mark