🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Harald Oehlmann Fri, 20 Nov 2026 10:55
#define Tcl_BounceObj Tcl_DecrObj for 8.6?
#133
Author: Harald Oehlmann
Date: Fri, 20 Nov 2026 10:55
18 lines
1577 bytes
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?

Then, a define like

#ifdef TCL8
#define Tcl_BounceObj Tcl_IncrObj
#endif

(I have no idea how to restrict a define on Tcl8, so upper is wrong there)

would be a good standard define for Tcl 8.6?

Thanks for all,
Harald
Re: #define Tcl_BounceObj Tcl_DecrObj for 8.6?
#135
Author: 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'
Re: #define Tcl_BounceObj Tcl_DecrObj for 8.6?
#136
Author: Harald Oehlmann
Date: Fri, 20 Nov 2026 13:10
68 lines
3274 bytes
Am 20.11.2026 um 12:46 schrieb Ralf Fassel:
> * 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'

Thanks, great!
My pattern in 8.6 is:

pKeyObj = Tcl_NewStringObj("key", -1);
Result = Tcl_DictObjGet(interp, pDeviceDict, pKeyObj, &pObj);
Tcl_DecrRefCount(pKeyObj);
if (Result != TCL_OK)
	return RET_ERROR;


I use Tcl_DecrRefCount to delete the object.
So, the right pattern would be:

8.6:
pKeyObj = Tcl_NewStringObj("key", -1);
Tcl_IncrRefCount(pKeyObj);
Result = Tcl_DictObjGet(interp, pDeviceDict, pKeyObj, &pObj);
Tcl_DecrRefCount(pKeyObj);
if (Result != TCL_OK)
	return RET_ERROR;

Tcl 9.0:
pKeyObj = Tcl_NewStringObj("key", -1);
Result = Tcl_DictObjGet(interp, pDeviceDict, pKeyObj, &pObj);
Tcl_BounceRefCount(pKeyObj);
if (Result != TCL_OK)
	return RET_ERROR;

Thanks for all,
Harald
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads