-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define close
method?
#5
Comments
Example:
|
FWIW, I just defined https://github.com/JuliaDB/CSV.jl/blob/c8abce00bee3d1a5631863fde03ea0d9caeef93f/src/Source.jl#L4 in CSV.jl. |
I'm not sure I understand what that does in CSV.jl - it accepts a stream and returns nothing? |
Since a |
Ah I see! so it's closed regardless, but the nothing returning method does nothing if a user calls it, rather than resulting in a program crash due to no method error? |
Yes, I think so. Just defining a |
Yes, I have methods that take an |
I've read some discussion of this today, aren't finalisers suboptimal? Something about the resources not being released even some time after GC. |
There's no perfect solution right now (see the discussions here: JuliaLang/julia#11207), but I do think that finalizers are the best way to go, because they ensure things get torn down eventually, and the user can call |
Having both finalizers and closing methods would be ideal. I think the |
So (and maybe this is stupid, I'm not sure, only just getting caught up on the discussion) is the answer then to have finializers for this, but then if close is called, to explicitly call the finalize method? |
I think ideally, one would always use finalizers and be able to call the |
This is closed by #21. |
I often use Libz streams in situations where I might be dealing with a regular
IOStream
or a compressed stream, which works pretty well, except I typically want to callclose(::IO)
to close my stream. I'm not sure ifclose
is applicable to a Libz stream, but maybe we could define a method anyway for theIO
interface?The text was updated successfully, but these errors were encountered: