* Cecil Westerhof <Cecil@decebal.nl>
| In Java you can use try with resources to open a file (resource) and
| you do not have to take care of the closing of the file. Does tcl has
| something like that?
Check the TCL 'try' command:
https://www.tcl.tk/man/tcl/TclCmd/try.html
While it does not automagically close the file handle, it allows to
close it in the 'finally' clause, no matter what. See the 'Examples'
section in the above manpage.
In Java you can use try with resources to open a file (resource) and
you do not have to take care of the closing of the file. Does tcl has something like that?
It does not work with an exit, but I do not mind that.
(At the moment.)
Yes that would work. I have:
proc tryWithFinally {} {
try {
puts "I am in the try"
return
} finally {
puts "Got in the finally"
}
}
tryWithFinally
and I get:
I am in the try
Got in the finally
It does not work with an exit, but I do not mind that.
(At the moment.)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 28:00:58 |
Calls: | 6,448 |
Files: | 12,050 |
Messages: | 5,254,475 |