-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improve forward compatibility with a notion of minimal modifier set #51
Comments
Syntax idea: |
I think there are two problems with the current behavior:
The above proposal improves on problem 1 (by putting some restrictions on the valid ways of inputting a variant, we make breakage less likely), but the fundamental issue remains... To really fix the issue, we should require that variants cannot have conflicting definitions: this means that a given set of modifiers cannot match two variants. For example (using @T0mstone's notation), if we have Intuitive specificationThe whole behavior can be specified intuitively with "aliases":
(These aliases are only used for resolving a variant. It's still a single variant, displayed as a single entry on the symbol page, but the entry would show I think this solves both problems:
It also preserves nice properties: modifiers are commutative, users can "build" their symbol by trying modifiers, and they can leave out optional modifiers. Formal specification
To resolve a set of modifiers |
As I originally wrote on Discord, from the user's perspective, your idea is really just a rephrasing of mine, with Moreover, I think this can be expressed in a simplified way to the user: each variant has required and optional modifiers, which makes it possible to allow using non-fully qualified names when it makes sense; however, no two variants can share the same set of required modifiers in order to prevent ambiguity. There might be some approximations, but this is what most users need to know understand the variant selection system. In the end, I think what we are discussing here is essentially an implementation detail which would not be observable to the end user.1 Footnotes
|
Yes I'm just adding this constraint and proposing another formulation. But the constraint is a bit tricky: "no two variants can share the same set of required modifiers" is not sufficient. For example (I think the alias formulation expresses the constraint correctly and in a way that's more concrete for users, but it's just one possible formulation.) |
This is what I meant by "There might be some approximations, but this is what most users need to know understand the variant selection system." Even if the phrasing is not complete (as in, correct, but missing some information), we just need the users to understand the general idea, and they can try the rest by themselves. |
Motivation
Currently, when selecting a variant from a set of modifiers, the first variant from the list that contains all the modifiers, and a minimal amount of additional modifiers, is chosen.12 This means using non-fully qualified names when referring to a symbol might cause breakage when Codex is updated. For example, consider the following symbol:
arrow.bar
resolves toarrow.r.bar
, which is ↦. Now, suppose a new version of Codex changes the symbol to the following:Now,
arrow.bar
will resolve toarrow.l.bar
, which is ↤.Essentially, this means adding new variants in the middle of the variant list can cause unexpected breakage. As of now, there is no policy regarding what constitute a breaking change when it comes to fallbacks.
Proposed solution
The intuitive idea of this solution is to make explicit what parts of the fully qualified form (i.e., which modifiers) can be omitted.
As before, each variant has a set of modifiers. Hereafter, we refer to this set of modifiers as the fully qualified form, denoted$M_\text{full}$ . Additionally, a variant can define a minimal modifier set, denoted $M_\text{min}$ , which is a subset of the fully qualified form (i.e., $M_\text{min} \subseteq M_\text{full}$ ). When selecting a variant for a set of modifiers $M$ , the same process as before is applied, with the additional constraint that the selected variant's minimal modifier set is included in $M$ (i.e., $M_\text{min} \subseteq M$ ).
The current behavior corresponds to having$M_\text{min} = \emptyset$ for all variants. With this proposal, the default would become $M_\text{min} = M_\text{full}$ , with lots of manual overrides to allow for backward compatibility and more leniency.
This improves forward-compatibility by explicitly specifying which fallbacks can be relied on, and which can't. Ideally, there could even be an automated way of detecting breakages. This is currently not feasible, because most breakages are not implicitly guaranteed to be future proof.3
Other benefits
As well as improving forward compatibility, this proposal can be the source of documentation improvements. Indeed, the current documentation45 only presents fully qualified names. For some common symbols, this can be problematic. For example,$M_\text{min}$ as the main symbol name and $M_\text{full}$ as the fully qualified name, when $M_\text{min} \neq M_\text{max}$ .
sym.errorbar.square.stroked
can be accessed through simplysym.errorbar
, but the documentation does not reflect that. With this proposal, the documentation can presentAs mentioned previously, this proposal would make it possible to detect breakages automatically, because it clarifies which non-fully qualified variants are legal and clearly defined, and which are not.
Footnotes
This is actually not defined in Codex, but in Typst. Making the variant selection part of Codex is the topic of Resolve modifiers #30. ↩
https://github.com/typst/typst/blob/d199546f9fe92b2d380dc337298fdca3e6fca8c8/crates/typst-library/src/foundations/symbol.rs#L387-L420 ↩
For example,
sym.angle.top
currently resolves tosym.angle.spheric.top
(⦡), but this is more a side effect of the fact that there is no baresym.angle.top
symbol than a conscious decision, and shouldn't be relied upon. ↩https://typst.app/docs/reference/symbols/sym/ ↩
https://typst.app/docs/reference/symbols/emoji/ ↩
The text was updated successfully, but these errors were encountered: