Roger-luo / Configurations.jl

Options & Configurations made easy.
https://configurations.rogerluo.dev/stable
MIT License
80 stars 12 forks source link

Naming disparity between `toml` & `from_toml` #10

Closed singularitti closed 3 years ago

singularitti commented 3 years ago

In the current implementation, toml can either return a String or write to a file. But in from_toml, the argument String can only refer to a file, not a valid TOML string. This raises inconsistency of naming convention. Will you consider adding configurations of JSON & YAML? What naming convention should they follow? How about naming to_file when you want to save to a file, from_file when you want to load from a file, and from_string when you want to load from a string, and to_string, etc.?

Roger-luo commented 3 years ago

Will you consider adding configurations of JSON & YAML?

No. There's already from_dict and to_dict, supporting these two should be easy in a new package or just write it as an one-liner. This package should not have a heavy dep, I support TOML mainly because it is shipped with Julia.

How about naming to_file when you want to save to a file, from_file when you want to load from a file, and from_string when you want to load from a string, and to_string, etc.?

since I will only support TOML in this package, there is no need to make it generic I think.

singularitti commented 3 years ago

Just one question: should toml be renamed to to_toml? Like from_dict & to_dict.

Roger-luo commented 3 years ago

yes, can you submit a PR for this?

singularitti commented 3 years ago

Sure, but this is a breaking change, is it? Should I make an alias to toml for backward compatibility? Or just upgrade to version 0.10.0?

Roger-luo commented 3 years ago

please also add a deprecation warning for toml, we can further discuss this in the PR.