|
2026-11-14
| ||
| 19:15 | • Closed ticket [7b0e690b70]: chan push returns channel ID plus 7 other change... artifact: 84f216ae9d user: oehhar | |
| 19:15 | [7b0e690b70] Document that chan push returns a channel ID check-in: f9df870831 user: oehhar tags: core-9-0-branch | |
| 19:13 | [7b0e690b70] Document that chan push returns a channel ID check-in: 520cc9fa7b user: oehhar tags: trunk, main | |
|
2026-10-14
| ||
| 15:31 | • Ticket [7b0e690b70] chan push returns channel ID status still Open with 2 ot... artifact: 82ea9a2a88 user: serhiy.storchaka | |
| 15:31 | • Ticket [2920003fff] chan push does not return the documented value status st... artifact: bdc7c7d0b7 user: serhiy.storchaka | |
| 15:31 | • Ticket [7b0e690b70] chan push returns channel ID status still Open with 4 ot... artifact: 56c05bd5e6 user: serhiy.storchaka | |
| 15:30 | Fix [7b0e690b70] and [2920003]: document that [chan push] returns the name of the channel, and that ... closed check-in: 766139d4e1 user: serhiy.storchaka tags: doc-chan-push-result | |
|
2015-12-27
| ||
| 10:54 | • Ticket [7b0e690b70] chan push returns channel ID status still Open with 3 ot... artifact: add020f19a user: sbron | |
|
2014-10-14
| ||
| 13:47 | • Ticket [7b0e690b70]: 4 changes artifact: d9be8e4e7d user: anonymous | |
| 02:01 | • Ticket [7b0e690b70]: 3 changes artifact: 199e016160 user: dgp | |
| 00:11 | • Ticket [7b0e690b70]: 4 changes artifact: 82833d2aa6 user: anonymous | |
|
2014-10-13
| ||
| 15:43 | • Ticket [7b0e690b70]: 3 changes artifact: 0f9ef17849 user: dgp | |
| 13:50 | • Ticket [7b0e690b70]: 4 changes artifact: f94df40993 user: anonymous | |
| 13:17 | • Ticket [7b0e690b70]: 4 changes artifact: f2141fd826 user: dkf | |
|
2014-10-05
| ||
| 00:09 | • New ticket [7b0e690b70]. artifact: 3c3d5c3cc8 user: anonymous | |
| Ticket UUID: | 7b0e690b70e84f3cb1d7278c3f160415514f5fa9 | ||
| Title: | chan push returns channel ID | ||
| Type: | Bug | Created on: | 2014-10-05 00:09:19 |
| Submitter: | anonymous | Assigned to: | nobody |
| Subsystem: | 26. Channel Transforms | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2026-11-14 19:15:38 |
| Status: | Closed | Closed by: | oehhar |
| Resolution: | Fixed | Closed on: | 2026-11-14 19:15:38 |
| Version: | 8.6.18, 9.0.5, 9.1.0 | ||
| Description: | ||||
The man page for [chan push] says that it returns a handle to the newly created transform, presumably the same handle that will be passed to the cmdprefix when it is called. Instead, it seems to be returning the channel ID.
First, I define a simple channel transform, "mychan", as a snit::type. Its initialize method looks like this:
typemethod initialize {handle mode} {
puts stderr "initialize $handle $mode"
}
Then:
% set f [open testfile.txt w]
file6
% set h [chan push $f mytrans]
initialize rt2 write
file6
%
In short, the initialize method is called, and the handle is rt2; but then [chan push] returns the channel ID, "file6".
| ||||
| User Comments: | ||||
dkf added on 2014-10-13 13:17:57:
I think it's just excessive copying of the documentation for chan create, and that we can just update to use language that describes what the code really does. anonymous (claiming to be will) added on 2014-10-13 13:50:45:
But if [chan push] doesn't return the handle that will be passed to the callback, there's no good way to relate the callback to the particular instance of [chan push]. dgp added on 2014-10-13 15:43:33:
Note that the value "file6" returned by [chan push] is now the name of the "base + transform" combination. It is *not* access to the base channel alone. Channel transforms have been written so that script level access to that base channel alone is not possible (until [chan pop] changes everything back, that is). The transformation driver routines get the identifier, so can code your driver to support many channels of the same kind. So, I think the [chan push] return value can do for you what I can imagine you would need. If I'm overlooking some use case that's broken, can you spell it out slowly for the dumb guy? Thanks. anonymous (claiming to be will) added on 2014-10-14 00:11:15:
Let me see if I can explain. I do a [chan push], and I register [mytrans]. Suppose I want [mytrans] to be able to access some data structure related to the particular instance of [chan push]. The logical way, given the way the man page is written, is to capture the transform handle returned by [chan push] and use it as a key into an array. But as it is, I can't do that. Instead I have to define my own key, pass it to [mytrans] as a prefix argument. OK, fine. But then, what's the point of passing the transform handle to the callback? It isn't good for anything except maybe debugging. And then, why bother passing the file handle back from [chan push]? You get back exactly the same name as you passed in, which you already had (even if it names something different now). It seems to me that having [chan push] do what the man page says might be useful, whereas the current behavior adds no value at all. [chan push] might as well return nothing. dgp added on 2014-10-14 02:01:59:
In my experience, setting up with that key into an array is what the initialize callback is for. See the test io-53.15 in the Tcl test suite for one example. As far as the utility of returning the channel name from [chan push], I presume that's to enable daisy chaining. set chan [chan push [open $path] mytrans] anonymous (claiming to be will) added on 2014-10-14 13:47:15:
Sure, you can make it work as it is; but it's an odd pattern. Somehow your code has to just know that the *next* initialize callback is related to the specific channel; there seems to be no way for it query and find out, unless you add your own key to the callback command. Seems like a recipe for fragile code to me. sbron added on 2015-12-27 10:54:38:
See also bug #2920003 serhiy.storchaka added on 2026-10-14 15:31:28:
As dkf, dgp and sbron (in [2920003]) concluded, it is the documentation that is wrong: [chan push] returns the name of the channel, which now refers to the channel with the transformation, and the handle passed to the handler is a separate identifier. Existing tests rely on the returned value being the channel. Proposed fix in branch doc-chan-push-result: chan.n and transchan.n are corrected. oehhar added on 2026-11-14 19:15:38:
Looks right. Commited to:
Closing. THanks for all, Harald | ||||
