News for hackers. Stuff that matters.
Re:Learn X in Y minutes – Tcl by sigzero on Tuesday August 25, 2015 @12:08PM (#10117440)
This illustrates how you can use Tcl to ensure that files get closed even when errors happen by combining catch, close and return (from the Tcl manual):

    proc withOpenFile {filename channelVar script} {
        upvar 1 $channelVar chan
        set chan [open $filename]
        catch {
            uplevel 1 $script
        } result options
        close $chan
        return -options $options $result
    }

There are no comments on this comment yet.