Some API comments and questions
nerochiaro at gmail.com
Thu Jan 19 10:16:09 CET 2006
> > 1) Files get opened in the constructor and get closed in the
> > destructor. While this is fine for C++ use, it does become
> > inconvenient when used from languages that rely on garbage collection.
> Why not just use a proxy object? i.e. Just create a class with the File
> methods and wrap those with (just using C++ here since I don't know Ruby):
I'm not sure I explained the problem correctly.
The problem is not checking if a file is closed, the problem is that a
lot of times there is need for the file to be closed _immediately_, in
a very specific point in the program.
In C++ you would say "delete my_file_obj" and the destructor would get
called immediately and the file would be closed.
Ruby can't do that because in Ruby you just say something like
"my_file_obj = nil" which means "I'm not using my_file_obj" anymore -
but that doesn't trigger the object destruction immediately at that
You have to wait a random amount of time for the garbage collector to
kick in and actually call delete on the object, and for all that
random time the file remains open.
That's why I say that having a method to _explicitly_ close the file
would be useful.
2) I will get back to you on the second point later. In general I
understand the rationale behind your design, and agree with you point
of using accessors/mutator methods.
There's still something that doesn't seem right to me (or that I don't
understand), but I need to check it with the code and I can't do that
More information about the taglib-devel