On Jun 4, 2011, at 7:55 PM, Peter Michaux wrote:

> Would we be able to do the following to ensure the file is closed if
> "fn" is either a function that throws or is a lambda that returns?
> 
>    var withFile = function(filename, fn) {
>        var file = openFile(filename);
>        try {
>            fn(file);
>        }
>        finally {
>            file.close();
>        }
>    };

Yes, finally clauses run on the way out due to return. The return from a lambda 
is like an exception, but not reified as such and not catchable. But finallys 
run.

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to