-
Notifications
You must be signed in to change notification settings - Fork 80
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
File constructor / FileBuilder API rework #49
Conversation
I wonder why you are not opting to represent the file constructor similar |
Because it's simpler this way, I think? Not everything from there makes sense here (e.g. read is always enabled; append doesn't really have the same meaning etc; exclusive write is a new thing here) and as such blindly duplicating it doesn't make sense either. Basically, my thought was - in Here, there's a few modes pre-defined in HDF5 and that's it ("append" synthetic mode is actually stolen from h5py and is just a convenient way of doing open-otherwise-create, it's not a built-in). Combining them doesn't make any sense whatsoever. So... instead of having 4/5 options and one finalizer, why not just have 5 finalizers (plus 1, the Plus, File::open_rw("foo.h5") without delving into docs of |
Anyhow, while this may not be the final iteration (if anyone has strong opinions on how the API should look like), I'm strongly convinced that the proposed version is better than using Here everything's strongly typed, and the most frequent use cases (open a file, create a new one, etc) become subjectively more simple and elegant. |
This is certainly a breaking change, but better sooner than later (initial discussion with @Enet4 a while ago in #14).
Main points:
File::open()
,File::open_rw()
,File::create()
,File::create_excl()
andFile::append()
(FileBuilder has those methods two as finishers).File::open_as()
which mimics previous behaviour, but is strongly typed and doesn't use string-based modes either (FileBuilder has it too).Example 1:
Example 2: