no.email at nospam.invalid
Mon Aug 30 09:22:17 CEST 2010
Steven D'Aprano <steve-REMOVE-THIS at cybersource.com.au> writes:
> I'm not saying that ref counting systems can avoid incrementing and
> decrementing the ref counts. That would be silly. But I'm saying that it
> is an accident of implementation that writing C extensions requires you
> to manually manage the counts yourself. That's a side-effect of
> permitting coders to write C extensions in pure C, rather than in some
> intermediate language which handles the ref counts for you but otherwise
> compiles like C. If people cared enough, they could (probably) make the C
> compiler handle it for them, just as it currently handles incrementing
> and decrementing the return stack.
I guess that is how the so-called smart pointers in the Boost C++
template library work. I haven't used them so I don't have personal
experience with how convenient or reliable they are, or what kinds of
constraints they imposed on programming style. I've always felt a bit
suspicious of them though, and I seem to remember Alex Martelli (I hope
he shows up here again someday) advising against using them.
I don't think a C compiler could really manage automatic decrementing
while still being C. Think especially of the common style of exception
handling in C using longjmp.
More information about the Python-list