scope() and FileConduit (D1 and Tango)
Bill Baxter
wbaxter at gmail.com
Fri Oct 3 14:40:02 PDT 2008
You might be interested in the siblings of scope(exit):
scope(success) and scope(failure).
In particular, scope(success) file.close(); is probably what you're after here.
--bb
On Sat, Oct 4, 2008 at 5:57 AM, Nick Sabalausky <a at a.a> wrote:
> I'd like some clarification on the way scope() works, and also Tango's
> FileConduit. In the following function:
>
> void load(char[] infilename)
> {
> auto file = new FileConduit(infilename);
> scope(exit) file.close();
>
> // Load data
> }
>
> What happens if infilename doesn't exist? Does FileConduit's constructor
> throw an exception? If so, file.close() isn't called, is it?
>
>
>
More information about the Digitalmars-d-learn
mailing list