Overview
| Artifact ID: | 9a7a998599c72069ac71444be2b609b1cb8fb6527f326bb025fa0e8aecbb469a |
|---|---|
| Ticket: | 648e2f961e7b20635b28219dda23917bc4d73f66
man try: better explain what happens if trap and finally executes regarding order and return value |
| User & Date: | oehhar on 2021-08-24 13:41:16 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- 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/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 - is_private changed to: "0"
- login: "oehhar"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "oehhar"
- subsystem changed to: "- New Builtin Commands"
- title changed to:
man try: better explain what happens if trap and finally executes regarding order and return value
- type changed to: "Bug"