Overview
| Artifact ID: | 996a317cce197ee92a538228dced84b3df4f405856917c9b8ba34493153a5891 |
|---|---|
| Ticket: | 5106fddd4400e5b9b063258b44f9685fb4750830
failure to yieldto is not the same thing as not calling yieldto in the first place |
| User & Date: | pooryorick on 2021-06-20 08:31:14 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
In the following script control eventually returns to p1, which sets <code>$done</code> to <code>success</code>. The fact that <code>$done1</code> has a final value of <code>failure</code> shows that the attempt to yield back to p1 failed, so how did control end up in p1 again? <code><verbatim> 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] </verbatim></code> <b>output:</b> <verbatim> status success failure </verbatim> If the script doesn't attempt the inner yieldto, and just sets the variables instead, the result is different: <code><verbatim> 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] </verbatim></code> <b>output:</b> <verbatim> status failure failure </verbatim> So apparently in the first script the failure to yield back to c1 affects some internal state and changes the outcome. - is_private changed to: "0"
- login: "pooryorick"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "pooryorick"
- subsystem changed to: "60. NRE and coroutines"
- title changed to:
failure to yieldto is not the same thing as not calling yieldto in the first place
- type changed to: "Bug"