>> I guess that when the parser opens the stream, it should also close it >> again. However,when an application opens a stream, I guess the >> application should open it. That leaves a problem with our Parser >> class >> opening streams... Ideas? > > Well, the "most polite" way of handling it would be to have the layer > that did the opening do the closing (if an application opens a stream > and passes it to the Parse (or Import or whatever it ends up being > named) > object, it ought to be left open for the application to close. If > a filename gets passed to the parse object to open, the parse object > should close it... > > On the other hand, that adds (slightly) to the necessary complexity > (Parse > object has to remember later whether it was passed an already-open > handle or > just a filename [or just text]). > If we WANTED to, it would probably be realistically reasonable to > simply > have the Parse layer or even the individual filetype parsers close > the filehandle when they get to the end. Kind of a toss-up, really. > > Probably the former option is the "better" one, if we want to deal with > it immediately. (If we adopt that, we'll want to do the same with the > filetype parsers, for the case where someone passes an filename/URL and > specifies the filetype...) Agreed. Let's every layer that opens one also close it when it (thinks) it is done with it. Nico