Skip to content
Tcl Source Code Artifact [5b3334f9e5]
Login

Artifact [5b3334f9e5]

Artifact 5b3334f9e5746d68ab140d42d5576472d7583dbfac5e927e8b3202bc54dd07bc:

Ticket change [5b3334f9e5] - Ticket [648e2f961e7b2063|648e2f961e] <i>man try: better explain what happens if trap and finally executes regarding order and return value</i> status still Open with 7 other changes by oehhar on 2021-08-25 08:12:31.
D 2021-08-25T08:12:31.866
J comment Dear\sTCL\steam,\r\n\r\nI\sam\shappy\swith\sthe\stry\scommand.\r\nMay\sI\spropose\ssome\senhancements\sto\sthe\sman\spage\sregarding\sa\strap\sand\sa\sfinally\sclause.\r\n\r\nIMHO,\sthe\sfollowing\sinformation\smay\sbe\sadded:\r\n\r\n<h2>Execution\sorder</h2>\r\n\r\nIf\sa\son/trap\sand\sa\sfinally\sclause\sis\spresent\sand\sexecuted,\sthe\strap\scode\sis\sexecuted\sbefore\sthe\sfinally\sclause.\r\n\r\n<h2>Return\svalue</h2>\r\n\r\nIf\sa\son/trap\sclause\sand\sa\sfinally\sclause\sis\spresent,\sthe\sfollowing\srules\scomply\sconcerning\sreturn\svalues:\r\n\r\n\s\s\s\s*\s\s\s\sIf\sonly\sthe\strap\sclause\sexecutes\sa\sreturn\scommand\sor\sraises\san\serror,\sthis\sreturn\svalue\sis\sreturned\sfrom\sthe\sprocedure\r\n\s\s\s\s*\s\s\s\sIf\sthe\sfinally\sclause\sexecutes\sa\sreturn\scommand\sor\sraises\san\serror,\sthis\sreturn\svalue\sis\sreturned\sfrom\sthe\sproc.\r\n\r\n<h2>Example\sfor\sorder\sand\sreturn\svalues</h2>\r\n\r\nAn\sexample\smay\sbe\sadded\slike\sthis:\r\n\r\n<verbatim>\r\nproc\swriteFile\s{}\s{\r\n\s\s\s\sset\sf\s[open\s/some/file/name\sa]\r\n\s\s\s\stry\s{\r\n\s\s\s\s\s\s\s\sputs\s$f\s"some\smessage"\r\n\s\s\s\s}\son\serror\s{}\s{\r\n\s\s\s\s\s\s\s\sputs\sstderr\s"Write\serror"\r\n\s\s\s\s\s\s\s\sreturn\s0\r\n\s\s\s\s\s\s\s\s#\s0\sis\sthe\sreturn\svalue\sin\scase\sof\san\serror\r\n\s\s\s\s\s\s\s\s#\sThe\sfinally\sclause\sis\sexecuted\safter\sthe\sreturn\sto\sclose\sthe\sfile\r\n\s\s\s\s}\sfinally\s{\r\n\s\s\s\s\s\s\s\scatch\s{close\s$f}\r\n\s\s\s\s}\r\n\s\s\s\sreturn\s1\r\n}\s\r\n}\r\n</verbatim>\r\n\r\nIMHO\sthis\sexample\sreally\sshows\sthe\spower\sand\suse-case\sof\sthe\sfinally\sclause.\r\n\r\nWhat\sdo\syou\sthink?\r\n\r\nHarald
J login oehhar
J mimetype text/plain
J priority 3\sLow
J private_contact 0f366eb3e9e2fcab52b8ebacd197db9047186a5f
J subsystem 18.\sCommands\sM-Z
J type RFE
K 648e2f961e7b20635b28219dda23917bc4d73f66
U oehhar
Z 2afd7fd64470badfb2749b02e9a4f822