Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-10-06
15:27 • Closed ticket [2093947fff]: coroutine+unset trace misfeature plus 3 other ch... artifact: 919bebfdc4 user: dkf
2008-09-05
20:14 • Ticket [2093947fff]: 4 changes artifact: 0ff5eb6278 user: dkf
08:22 • Ticket [2093947fff]: 6 changes artifact: 9cd13ec590 user: msofer
2008-09-04
22:48 • New ticket [2093947fff]. artifact: f302711978 user: dkf

coroutine+unset trace misfeature

Closed / Fixed2093947fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-09-04 22:48:00
I've been experimenting with traces and coroutines as part of the discussion on http://wiki.tcl.tk/21537 (as to why Lars's proposal isn't good enough) and I came across this:

$ make shell
% proc foo {} {set v 1; trace add variable v {write unset} bar; yield; set v 2; yield; set v 3}
% proc bar args {puts $args};namespace path tcl::unsupported;coroutine a foo
% a
v {} write
% a
v {} write
v {} unset
3
% a
ambiguous command name "a": after append apply array atProcExit auto_execok auto_import auto_load auto_load_index auto_qualify
% coroutine a foo
% a
v {} write
% rename a {}
% a
ambiguous command name "a": after append apply array atProcExit auto_execok auto_import auto_load auto_load_index auto_qualify

It would be *very* nice if variable unset traces were run when a coroutine is "deleted early" since that would mean that the assumption that unset traces could be used to handle scoping of resource lifetime to procedure body execution lifetime was guaranteed. And in a strong sense, the variables are unset when the created coroutine is deleted.

There's probably also a related issue with tailcall not calling unset traces on local variables, but I've not checked. ;-)

I'm sorry these things make stuff messier. Resolving them would, I think, go a long way towards making the NRE stuff fit to come out of the tcl::unsupported closet.
msoferplain2008-09-05 08:22:10
Logged In: YES 
user_id=148712
Originator: NO

Fixed in HEAD: insure that unset traces ignore the "execEnvPtr->rewind" that signals coroutine deletion.

Leaving open and reassigning: should the same thing be done for unwinding when interpreter limits are violated? When unwinding the interp? Possibly ... possibly not.
dkfplain2008-09-05 20:14:46
Logged In: YES 
user_id=79902
Originator: YES

Traces should run when unwinding when a limit is violated, but *not* if those traces involve executing further Tcl code in the interpreter that's over the limit. Traces in C should be OK.
dkf Closed ticket [2093947fff]. [History diff]2008-10-06 15:27:51
Log in (anonymous is fine) to add a comment.