Skip to content
Tcl Source Code History Of Ticket 5106fddd4400e5b9b
Login

History Of Ticket 5106fddd4400e5b9b

Artifacts Associated With Ticket 5106fddd4400e5b9b

  1. Ticket change [996a317cce] (rid 194920) by pooryorick on 2021-06-20 08:31:14:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized 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.
      
    5. is_private initialized to: "0"
    6. login: "pooryorick"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Important"
    10. status initialized to: "Open"
    11. submitter initialized to: "pooryorick"
    12. subsystem initialized to: "60. NRE and coroutines"
    13. title initialized to:
      failure to yieldto is not the same thing as not calling yieldto in the first place
      
    14. type initialized to: "Bug"
  2. Ticket change [6c43e1b849] (rid 194935) by pooryorick on 2021-06-21 05:44:05:

    1. icomment: "Duplicate of [f9800d52bd61f240]."
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Duplicate"
  3. Ticket change [9ca64d8252] (rid 194936) by pooryorick on 2021-06-21 05:44:32:

    1. assignee changed to: "pooryorick"
    2. login: "pooryorick"
    3. mimetype: "text/plain"
    4. status changed to: "Pending"
  4. Ticket change [64043e7cfe] (rid 194938) by pooryorick on 2021-06-21 05:56:04:

    1. icomment: "Test case added in [5cfdd6ee7b7f2099]."
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [e7755fc22e] (rid 195035) by pooryorick on 2021-06-23 18:53:20:

    1. closedate changed to: "2459389.28704361"
    2. closer changed to: "pooryorick"
    3. login: "pooryorick"
    4. mimetype: "text/plain"
    5. status changed to: "Closed"