Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2021-06-23
18:53 • Closed ticket [5106fddd44]: failure to yieldto is not the same thing as not call... artifact: e7755fc22e user: pooryorick
2021-06-21
05:56 • Ticket [5106fddd44]: 3 changes artifact: 64043e7cfe user: pooryorick
05:44 • Pending ticket [5106fddd44]. artifact: 9ca64d8252 user: pooryorick
05:44 • Ticket [5106fddd44]: 4 changes artifact: 6c43e1b849 user: pooryorick
05:40
test for issue [5106fddd4400e5b9b], failure to yieldto is not the same thing as not calling yieldto ... check-in: d7428a1ea0 user: pooryorick tags: bug-f9800d52bd61f240
2021-06-20
08:31 • New ticket [5106fddd44] failure to yieldto is not the same thing as not calling ... artifact: 996a317cce user: pooryorick

failure to yieldto is not the same thing as not calling yieldto in the first place

Closed / Duplicate5106fddd4400e5b9b063258b44f9685fb4750830Created 5 years agoUpdated 5 years ago
Descriptionwiki2021-06-20 08:31:14
In the following script control eventually returns to p1, which sets $done to success. The fact that $done1 has a final value of failure shows that the attempt to yield back to p1 failed, so how did control end up in p1 again?

variable done
proc p0 {} {
	yield
	variable done0
	after 0 [list [namespace which c1]]
	vwait [namespace current]::done0
}


proc p1 {} {
	variable done0
	yield
	yieldto try "yieldto [list [info coroutine]]" on error {} "
		::set [list [namespace current]]::done1 failure
		::set [list [namespace current]]::done0 failure
	"
	set done0 success
}

coroutine c0 p0
coroutine c1 p1
after 1 [list [namespace which c0]]
vwait [namespace current]::done0
puts [list status $done0 $done1]

output:

status success failure

If the script doesn't attempt the inner yieldto, and just sets the variables instead, the result is different:

variable done
proc p0 {} {
	yield
	variable done0
	after 0 [list [namespace which c1]]
	vwait [namespace current]::done0
}


proc p1 {} {
	variable done0
	yield
	yieldto try "
		::set [list [namespace current]]::done1 failure
		::set [list [namespace current]]::done0 failure
	"
	set done0 success
}

coroutine c0 p0
coroutine c1 p1
after 1 [list [namespace which c0]]
vwait [namespace current]::done0
puts [list status $done0 $done1]

output:

status failure failure

So apparently in the first script the failure to yield back to c1 affects some internal state and changes the outcome.

pooryorickwiki2021-06-21 05:44:05

Duplicate of [f9800d52bd61f240].

pooryorick Pending ticket [5106fddd44]. [History diff]2021-06-21 05:44:32
pooryorickwiki2021-06-21 05:56:04

Test case added in [5cfdd6ee7b7f2099].

pooryorick Closed ticket [5106fddd44]. [History diff]2021-06-23 18:53:20
Log in (anonymous is fine) to add a comment.