Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AlexIIL
Copy link
Contributor

@AlexIIL AlexIIL commented Feb 12, 2023

@Akarys42 Akarys42 changed the title Treat dashes and underscores as the same when comparing mod ids RFC 0070: Treat dashes and underscores as the same when comparing mod ids Apr 14, 2023
@LambdAurora LambdAurora added the loader RFCs that affect the Quilt Loader specifically. label Apr 15, 2023
Copy link
Contributor

@Leo40Git Leo40Git left a 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.
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":

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

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

## 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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
loader RFCs that affect the Quilt Loader specifically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants