🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.tcl
Article #135

Re: #define Tcl_BounceObj Tcl_DecrObj for 8.6?

#135
From: Ralf Fassel
Date: Fri, 20 Nov 2026 11:46
35 lines
2342 bytes
* Harald Oehlmann <wortkarg3@yahoo.com>
| I am not sure when to use Tcl_BounceObj in Tcl 9.
| I only know, that there are many error issues with the abstract list.
| Is it adviceable to:
| - replace Tcl_DecrObj by Tcl_BounceObj in TCL 9?
| - still use Tcl_DecrObj in TCL 8.6?

ITYM Tcl_BounceRefCount?

Looking at the source code (Tcl9.0.4), Tcl_BounceRefCount only frees the
Tcl_Obj if the refcount is already 0.

I *think* the intention is to replace
   obj = Tcl_NewObj();
   Tcl_IncrRefCount(obj);
   // do anything with obj that does *not* incr/decr the refcount
   Tcl_DecrRefCount(obj);
by
   obj = Tcl_NewObj();
   // do anything with obj that does *not* incr/decr the refcount
   Tcl_BounceRefCount(obj);

i.e. to avoid the Incr/Decr combo.  

Note however that if "do anything with obj" modifies the refcount, it is
necessary to IncrRefCount before calling it, in which case you need to
use Tcl_DecrRefCount, not Tcl_BounceRefCount.

This means that simply replacing *any* Tcl_DecrRefCount by
Tcl_BounceRefCount is wrong, only replacing a *matching*
Tcl_IncrRefCount/Tcl_DecrRefCount by Tcl_BounceRefCount would be
(sometimes :-) ok.

My €0.01
R'
Technical Details
Message-ID: <ygase0v4ter.fsf@akutech.de>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11dp90e$33fif$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Ralf Fassel <ralfixx@gmx.de>
Newsgroups: comp.lang.tcl
Subject: Re: #define Tcl_BounceObj Tcl_DecrObj for 8.6?
Date: Fri, 20 Nov 2026 12:46:36 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <ygase0v4ter.fsf@akutech.de>
References: <11dp90e$33fif$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 20 Nov 2026 11:46:37 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3244414"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/xgjOc1HikyUd67zaoBTjg"; posting-host="0dd4c21b3b45f1e759a1702a0e2e533f"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:Ixwf9rAuy1OlpfkdYQL3olsAPyw=
	sha1:qDOo+TIfQMCeicosroUICCXpJDY= sha256:xraPQKaQRc1AKzSucuMPIN+Vh5gOwZGmyZq+JIsiYxM=
	sha1:UyzhVXSbjzBp+Or+Hqb4b/Iee70= sha256:f1TZgBVQ4AnwDxR6jwYe+ctRkJCume9b0JQMGhGdnhc=