-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
RFC 0070: Treat dashes and underscores as the same when comparing mod ids #70
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar fixup.
Not sure what spelling of "normalise" should be used?
|
||
## Summary | ||
|
||
Treat dashes and underscores as the same for mod id comparison purposes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Treat dashes and underscores as the same for mod id comparison purposes. | |
Treat dashes and underscores as the same for mod identifier (ID) comparison purposes. |
|
||
## Motivation | ||
|
||
An occasional cause for confusion is when two different mods only differ by underscores (`_`) and dashes(`-`) in their mod-ids. Since those characters aren't usually used to discriminate between mods, I propose we consider them as the same for the purposes of mod resolution and solving. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An occasional cause for confusion is when two different mods only differ by underscores (`_`) and dashes(`-`) in their mod-ids. Since those characters aren't usually used to discriminate between mods, I propose we consider them as the same for the purposes of mod resolution and solving. | |
An occasional cause for confusion is when two different mods only differ by underscores (`_`) and dashes(`-`) in their mod IDs. Since those characters aren't usually used to discriminate between mods, I propose we consider them as the same for the purposes of mod resolution and solving. |
|
||
## Explanation | ||
|
||
I propose we normalise all quilt mod-ids by replacing every dash (`-`) and underscore (`_`) with an internal character (likely `#`, but any character that's not permitted by the specification, and is unlikely to be part of the specification in the future, would work. Ascii is preferable due to string optimisations though). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose we normalise all quilt mod-ids by replacing every dash (`-`) and underscore (`_`) with an internal character (likely `#`, but any character that's not permitted by the specification, and is unlikely to be part of the specification in the future, would work. Ascii is preferable due to string optimisations though). | |
I propose we normalise all Quilt mod IDs by replacing every dash (`-`) and underscore (`_`) with some internal character (one that is not permitted by the specification). |
Moved this discussion down to the "Unresolved questions" section.
|
||
This normalisation would purely happen internally to quilt-loader, and wouldn't be shown to users, or exposed in methods like `ModContainer.getId()`. Instead this would allow dependencies and breaks to accidently target the wrong ID without causing issues, and would automatically cause mods with underscores or dashes to "provide" the other representations automatically. | ||
|
||
For example, a mod with an ID "potion_craft-expanded" would result in: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, a mod with an ID "potion_craft-expanded" would result in: | |
For example, with a mod with the ID "potion_craft-expanded": |
For example, a mod with an ID "potion_craft-expanded" would result in: | ||
- `QuiltLoader.getModContainer("potion_craft-expanded")` would return the mod | ||
- `QuiltLoader.getModContainer("potion-craft-expanded")` would return the same mod | ||
- The same mod is also returned for strings `potion_craft_expanded` and `potion-craft_expanded` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The same mod is also returned for strings `potion_craft_expanded` and `potion-craft_expanded` | |
- The same mod is also returned for `potion_craft_expanded` and `potion-craft_expanded` |
- `QuiltLoader.isModLoaded` would return true for all 4 strings | ||
- `QuiltLoader.getEntrypoints` would return the same entrypoint list for each id. | ||
- `QuiltLoader.getAllMods()` will only contain a single entry | ||
- `ModMetadata.provides()` would NOT contain provided entries for every possible combination, instead it would be empty (if no provided entries exist in the quilt.mod.json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `ModMetadata.provides()` would NOT contain provided entries for every possible combination, instead it would be empty (if no provided entries exist in the quilt.mod.json) | |
- `ModMetadata.provides()` would NOT contain provided entries for every possible combination, instead it would be empty (unless the mod defines `provided` entries in its quilt.mod.json) |
## Rationale and Alternatives | ||
|
||
We could instead normalise all dashes to underscores (or vice versa) but that has a few issues: | ||
* During debugging, it won't be easy to tell if a string contains a normalised modid or a non-normalised id, leading to more bugs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* During debugging, it won't be easy to tell if a string contains a normalised modid or a non-normalised id, leading to more bugs. | |
* During debugging, it won't be easy to tell if a string contains a normalised mod ID or a non-normalised id, leading to more bugs. |
* We'd have to choose a favourite character, which could result in a fairly lengthy debate. Sidestepping that seems useful. | ||
|
||
We could even remove both characters entirely during normalisation, so `quilt_loader` would get normalised to `quiltloader`. However this has another problem, in addition to those listed above: | ||
* It disallows the use of separator characters in mod-ids, which are genuinly quite useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* It disallows the use of separator characters in mod-ids, which are genuinly quite useful. | |
* It disallows the use of separator characters in mod IDs, which are genuinely quite useful. |
|
||
## Prior Art | ||
|
||
I'm not aware of forge, fabric, or quilt related projects doing this before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not aware of forge, fabric, or quilt related projects doing this before. | |
I'm not aware of Forge, Fabric, or Quilt related projects doing this before. |
I'm not certain what character should be used, but '#' seems like a good candidate. | ||
I'm not sure if calls to `QuiltLoader.getModContainer` or `QuiltLoader.isModLoaded` using the normalised ID should return the mod, null, or if that should be left unspecified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain what character should be used, but '#' seems like a good candidate. | |
I'm not sure if calls to `QuiltLoader.getModContainer` or `QuiltLoader.isModLoaded` using the normalised ID should return the mod, null, or if that should be left unspecified. | |
- I'm not certain what character should be used, but '#' seems like a good candidate. Any character that's not permitted by the specification, and is unlikely to be part of the specification in the future, would work - though, ASCII is preferable due to string optimisations. | |
- I'm not sure if calls to `QuiltLoader.getModContainer` or `QuiltLoader.isModLoaded` using the normalised ID should return the mod, null, or if that should be left unspecified. |
Rendered View