Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions rfc/0070-normalise-mod-ids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Normalise Mod ID Separators

## Summary

Treat dashes and underscores as the same for mod id comparison purposes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).
Copy link
Contributor

@Leo40Git Leo40Git May 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, a mod with an ID "potion_craft-expanded" would result in:
For example, with a mod with the ID "potion_craft-expanded":

- `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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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`

- The returned `ModContainer` will return `potion_craft-expanded` from `ModContainer.metadata().id()`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The returned `ModContainer` will return `potion_craft-expanded` from `ModContainer.metadata().id()`.
- The resulting `ModContainer` will report `potion_craft-expanded` as its ID (from `ModContainer.metadata().id()`).

- `QuiltLoader.isModLoaded` would return true for all 4 strings
- `QuiltLoader.getEntrypoints` would return the same entrypoint list for each id.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `QuiltLoader.getEntrypoints` would return the same entrypoint list for each id.
- `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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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)



## Drawbacks

If someone intentionally uses dashes and underscores as a way to differentiate mods then their mods will be broken by this change. Personally I think this is unlikely though.


## 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.


## Unresolved questions

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.
Comment on lines +48 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.