Skip to content
Tcl Source Code History Of Ticket 648e2f961e
Login

History Of Ticket 648e2f961e

Artifacts Associated With Ticket 648e2f961e

  1. Ticket change [9a7a998599] (rid 195504) by oehhar on 2021-08-24 13:41:16:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      Dear TCL team,
      
      I am happy with the try command.
      May I propose some enhancements to the man page regarding a trap and a finally clause.
      
      IMHO, the following information may be added:
      
      <h2>Execution order</h2>
      
      If a on/trap and a finally clause is present and executed, the trap code is executed before the finally clause.
      
      <h2>Return value</h2>
      
      If a on/trap clause and a finally clause is present, the following rules comply concerning return values:
      
          *    If only the trap clause executes a return/error command, this return value is returned from the procedure
          *    If the finally clause executes a return/error command, this return value is returned from the proc.
      
      <h2>Example for order and return values</h2>
      
      An example may be added like this:
      
      <verbatim>
      proc writeFile {} {
          set f [open /some/file/name a]
          try {
              puts $f "some message"
          } on error {} {
              puts stderr "Write error"
              return 0
              # 0 is the return value in case of an error
              # The finally clause is executed after the return to close the file
          } finally {
              close $f
          }
          return 1
      } 
      }
      </verbatim>
      
      IMHO this example really shows the power and use-case of the finally clause.
      
      What do you think?
      
      Harald
      
    5. is_private initialized to: "0"
    6. login: "oehhar"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Minor"
    10. status initialized to: "Open"
    11. submitter initialized to: "oehhar"
    12. subsystem initialized to: "- New Builtin Commands"
    13. title initialized to:
      man try: better explain what happens if trap and finally executes regarding order and return value
      
    14. type initialized to: "Bug"
  2. Ticket change [5b3334f9e5] (rid 195505) by oehhar on 2021-08-25 08:12:31:

    1. comment changed to:
      Dear TCL team,
      
      I am happy with the try command.
      May I propose some enhancements to the man page regarding a trap and a finally clause.
      
      IMHO, the following information may be added:
      
      <h2>Execution order</h2>
      
      If a on/trap and a finally clause is present and executed, the trap code is executed before the finally clause.
      
      <h2>Return value</h2>
      
      If a on/trap clause and a finally clause is present, the following rules comply concerning return values:
      
          *    If only the trap clause executes a return command or raises an error, this return value is returned from the procedure
          *    If the finally clause executes a return command or raises an error, this return value is returned from the proc.
      
      <h2>Example for order and return values</h2>
      
      An example may be added like this:
      
      <verbatim>
      proc writeFile {} {
          set f [open /some/file/name a]
          try {
              puts $f "some message"
          } on error {} {
              puts stderr "Write error"
              return 0
              # 0 is the return value in case of an error
              # The finally clause is executed after the return to close the file
          } finally {
              catch {close $f}
          }
          return 1
      } 
      }
      </verbatim>
      
      IMHO this example really shows the power and use-case of the finally clause.
      
      What do you think?
      
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/plain"
    4. priority changed to: "3 Low"
    5. private_contact changed to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
    6. subsystem changed to: "18. Commands M-Z"
    7. type changed to: "RFE"