Repository navigation
Discussing v4 API Changes #253
Replies: 12 comments 11 replies
I'd like to understand the specific meaning behind renaming Even if it's for adding options, the standard library's I've read your latest v3-to-v4-migration documentation, and similar renamings have occurred in At least from the documentation, aside from increasing the migration cost for users and creating inconsistencies with naming conventions other serialization libraries, I don't see any improvement. So, is this change an attempt to forcibly bring naming conventions from other languages (perhaps Python, whose standard library uses |
When we started thinking about options, we actually needed to change the names from
Load and Dump are also not direct equivalents to Encode and Decode. They are a level above them. A YAML loader stack is shown here: https://github.com/yaml/go-yaml/blob/main/docs/how-go-yaml-works.md#the-big-picture-paired-pipelines Decode only went up to the Resolve level. v4 will provide support for full Construction and Representation. This was not a cosmetic change at all. It was simply fortunate that the API names Load and Dump were not already used. We don't have to deprecate Marshal/Unmarshal and Encode/Decode but we realized they don't offer anything special that you can't do with the Dump/Load API. |
As I mentioned earlier, Go supports variable arguments, meaning we don't need a new Additionally, you mentioned "don't have to deprecate" but based on the migration documentation, this might be unclear. It makes it seem as if the old API is deprecated, and users should or even must migrate to the new From a migration perspective, this is also confusing. If simply changing the name can essentially keep the existing code unchanged, then why change the name? |
I'll call on @ccoVeille and others to explain why we couldn't simply extend Encode/Decode, or you might find it in #162 (as I mentioned earlier).
We don't have to deprecate those the legacy API in v5, but it makes no sense to keep it as it offers nothing extra from the new API (beyond the names you prefer), and we'd have to maintain all that.
I tried to explain above that it is far from a name change. v4 makes the transition from v3 nearly seamless. It offers options and plugins to take YAML to almost any level imaginable.
This go-yaml library wants to be the best YAML library, not only for Go, but also for YAML. I lead the YAML language maintenance effort as a whole, but I want to do right by both YAML and Go (and the other YAMLs I maintain). Fortunately we have a team of people who are as passionate about Go as I am about YAML. |
For advanced users, migrating from However, using |
|
I read through https://github.com/yaml/go-yaml/blob/main/docs/v3-to-v4-migration.md and I agree it could be improved. |
|
@wwqgtxx One other thing that Dump/Load allowed us to do was change the default options without breaking existing code. |
|
Based on the current changes, the only style difference between V3 and V4 is in Inform users that we have modified the default output behavior. If these changes affect existing tests or other needs, they can manually change it to I agree with you that a new function name for Given Go's sumver system, migrating from V3 to V4 is practically impossible without any manual intervention (at least manual modification of the import path is required). Therefore, it's unlikely that users will unknowingly use the V4 library due to passive updates. Modifying some default values doesn't seem surprising; it just needs to be clearly stated in the migration documentation. (The only exception is for users who already rely on the RC version of the V4 library, but they should be aware of the risks of using the RC version.) |
|
I was hoping that @ccoVeille would explain here why we can't extend Encode/Decode or Marshal/Unmarshal with variadic options. @ccoVeille created an earlier API options attempt that used new API names like EncodeWithOptions etc. To your point on v5, by then our options system will be well understood and we can default to new v5 options, requiring people to use yaml.v4 if they upgraded but didn't want the new v5 defaults. |
|
Submitted #258 to not deprecate the existing APIs. |
|
@ccoVeille We need to release our main development under a v4 tag because we made very strong and explicit commitments to major adopters at the start of this project, that the v2 and v3 branches and releases would only contain necessary security level changes. Given the level of new additions to the library, there are many more reasons why we should do v4. |
|
@ingydotnet Are you open to the idea of incremental parsing support? I am trying to use this library to implement LSP functionality, and Tree Sitter style byte offset handling, partial parsing and reparsing, dirty nodes in a tree, etc... would all be HUGE for downstream logic. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This discussion started in issue #237.
That issue was copied to #251 using this script https://gist.github.com/ingydotnet/7065adced8e48514a7e41cd96b144349
Then #251 was converted into this discussion.
All reactions