I was not expecting this to throw an error. Docs says it should return 0
or 1. How would you do this check?
% package req Thread
2.8.5
% thread::exists ""
invalid thread handle ""
% thread::exists abc
invalid thread handle "abc"
But then this works:
% thread::exists tid1
0
Weird. It looks like the check expects the argument to start with "tid"
and a number.
Am 08.02.2026 um 20:05 schrieb saito:
I was not expecting this to throw an error. Docs says it should return
0 or 1. How would you do this check?
% package req Thread
2.8.5
% thread::exists ""
invalid thread handle ""
% thread::exists abc
invalid thread handle "abc"
But then this works:
% thread::exists tid1
0
Weird. It looks like the check expects the argument to start with
"tid" and a number.
Yes, please file a bug report:
https://core.tcl-lang.org/thread/ticket
Finally, IMO please do not create a ticket.
BR,--- Synchronet 3.21b-Linux NewsLink 1.2
Christian
At Sun, 8 Feb 2026 22:40:39 +0100 undroidwish <undroidwish@googlemail.com> wrote:
Finally, IMO please do not create a ticket.
The OP is NOT expecting thread::exists to behave any differently than it does,
just that thread::exists behavior be completely and accurately documented. Appearently, the documentation is mute as to what thread::exists does when given a string that is not a proper thread id, with the (erronious) *presumption* that it would return 0 (which is in fact NOT what it does). This
is a *documentation* bug. And the suggested bug report relates to the *documentation*, not the actual code.
If it is important, then it should be documented. You think it is "tid" followed by numbers? Not so. Why is "tidabc" ok here but not "tidxyz"?
% thread::exists tidabc
0
% thread::exists tidxyz
invalid thread handle "tidxyz"
Hi Chrstian, all,
I am very happy about the discussion.
Ihe intention to file a bug report is to have this discussion in a
ticket and not here. So the discussion may be found later.
Hi Chrstian, all,
I am very happy about the discussion.
Ihe intention to file a bug report is to have this discussion in a
ticket and not here. So the discussion may be found later.
About "error or not".
Most "exists" functions in TCL don't throw errors on invalid arguments.
For example,
dict exits {} a b
has thrown an error in an earlier version of TCL.
This was changed to not throw an error.
Am 09.02.26 um 08:22 schrieb Harald Oehlmann:The problem is that this is NOT documented. The documentation should document this behaviour.
Hi Chrstian, all,
I am very happy about the discussion.
Ihe intention to file a bug report is to have this discussion in a
ticket and not here. So the discussion may be found later.
About "error or not".
Most "exists" functions in TCL don't throw errors on invalid arguments.
For example,
dict exits {} a b
has thrown an error in an earlier version of TCL.
This was changed to not throw an error.
I tend to agree with the other Christian. If Tcl had types, then the
argument to thread::exists would be a Thread identifier and there would
not be a way to pass some artbitrary object to it. The purpose of this function is to see, if a thread identifier - something you got back from thread::create - corresponds to a running thread. If you pass it
something which is not a thread identifier, than there is a bug in your program.
Christian
Am 09.02.26 um 08:22 schrieb Harald Oehlmann:
If you pass it
something which is not a thread identifier, than there is a bug in your program.
I tend to agree with the other Christian. If Tcl had types, then the argument to thread::exists would be a Thread identifier and there would
not be a way to pass some artbitrary object to it. The purpose of this function is to see, if a thread identifier - something you got back from thread::create - corresponds to a running thread. If you pass it
something which is not a thread identifier, than there is a bug in your program.
...
My original question remains: "How would you do this check?" when you receive a thread id from an evil user or colleague or simply by mistake?
On 2/9/26 23:47, saito wrote:
...
My original question remains: "How would you do this check?" when you
receive a thread id from an evil user or colleague or simply by mistake?
Due to the nature of threads their sheer existence is bound to their containing process. Are there real use cases where a thread identifier
is given to the process' outer world?
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 59 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 19:53:29 |
| Calls: | 812 |
| Calls today: | 2 |
| Files: | 1,287 |
| D/L today: |
20 files (23,248K bytes) |
| Messages: | 210,075 |