On Mon, Apr 28, 2014 at 06:06:32PM +1000, Peter B. West wrote: > This is the technique used in the old contrib/io.clj read-lines > function, isn't it? That's handy to know.
Correct. > Still, Stuart is skeptical about it. I don't think it's a good general solution to the problem, so Stuart's skepticism is fair. For specific cases where you know how the sequence will be used, though, it can be acceptable. > And they don't use with-open. So I guess with-open is a bit of > problem, and you're back to managing file closing by yourself, which > is what with-open was trying to circumvent, wasn't it? with-open is only good for cases where your resource's scope is easily contained within a form's evaluation. It's not designed for cases where the resource "escapes" from the form, which is what you're trying to do. In cases like that you can either try to force with-open to do what you want (by tying up a thread and waiting on a signal, as you've attempted to do), or you can handle closing the resource yourself (tying up no threads and explicitly performing the close). Essentially: with-open is designed for one specific use case but what you're trying to do doesn't fit into that, so you need to use a different solution. If you can't contain the entire resource's lifetime in a single scope (ie. have the with-open enclose the entire time when the resource is used), then you need to open/close it yourself some other way.
signature.asc
Description: Digital signature