Skip to content

(Design) Exact Match Selector Options #557

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

Merged
merged 8 commits into from
Dec 18, 2023

Conversation

aphillips
Copy link
Member

In response to #433 we need to choose a name for the "exact match" selector.

This isn't done yet but will serve as a foundation for choosing.

In response to #433 we need to choose a name for the "exact match" selector.

This isn't done yet but will serve as a foundation for choosing.
@eemeli
Copy link
Collaborator

eemeli commented Dec 8, 2023

I'm not sure how to best express this in the design doc, but please feel to add this as appropriate: One yardstick that I think is rather relevant here is what happens when the value we're selecting on is not a string, but e.g. a number.

Put another way, substituting each of the options for :xxx, which pattern gets selected here, and what would a reader expect based on the function name?

.local $num = {1 :number}
.match {$local :xxx}
1.0 {{Very one}}
1   {{Integral one}}
one {{Category one}}
*   {{Not one}}

With :select, :exact and :equals, no hint is given that anything like a type cast might be happening here, so a reader could very easily presume that the comparison is numeric, and that therefore Very one would get selected, as it's before the Integral one.

My preference here would be for :string, which more clearly communicates that its input value is stringified and then compared, and that the Integral one pattern is therefore selected.

@aphillips aphillips added functions Issue pertains to the default function set normative Issue affects normative text in the specification labels Dec 11, 2023
@aphillips
Copy link
Member Author

In the 2023-12-11 teleconference we decided to use :string. I have updated this PR to reflect that choice.

Copy link
Collaborator

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

Overall looks good, but see inline comments.

Comment on lines 30 to 33
The exact match selector function is the function used when an implementation
cannot find another selector.
It is also an attribute of selectors, such as `:number` or perhaps `:date`
that need to match specific values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The exact match selector function is the function used when an implementation
cannot find another selector.
It is also an attribute of selectors, such as `:number` or perhaps `:date`
that need to match specific values.
The exact match selector function is the simplest selection function,
which compares its input to the variant keys using string equality.
Other selectors, such as `:number` or perhaps `:date`
may provide similar functionality for their supported value types.

Copy link
Member Author

Choose a reason for hiding this comment

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

Minor tweaks to this suggestion.

Suggested change
The exact match selector function is the function used when an implementation
cannot find another selector.
It is also an attribute of selectors, such as `:number` or perhaps `:date`
that need to match specific values.
The exact match selector function is the simplest selector function,
which compares its operand to the variant keys using string equality.
Other selectors, such as `:number` and `:date` usually
provide similar functionality for their supported value types.

Note that both your (@eemeli) suggestion and mine lose the "defaultness" of this selector. Do you disagree with saying that this is the selector used when no other selector's signature matches?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah. It looks like we accidentally dropped a line in #441 that was added in #431:

- Each _selector_ MUST have an _annotation_,
or contain a _variable_ that directly or indirectly references a _declaration_ with an _annotation_.

In other words, we've resolved not to have a fallback or default selector. Instead, one must always be defined. I'll add a PR re-introducing that line.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Otherwise, your suggestion is good, and with that I'm happy to approve this.

Comment on lines 30 to 33
The exact match selector function is the function used when an implementation
cannot find another selector.
It is also an attribute of selectors, such as `:number` or perhaps `:date`
that need to match specific values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Otherwise, your suggestion is good, and with that I'm happy to approve this.

We require annotations, so the text was inappropriate in the "background" section. Fixed it to be consistent with our policy/syntax/etc.
@aphillips aphillips requested a review from eemeli December 16, 2023 16:52
@aphillips
Copy link
Member Author

@eemeli I fixed the text, so check it again? You were right that we lost the normative text about annotations--and I wrote this not thinking of that.


_Describe the proposed solution. Consider syntax, formatting, errors, registry, tooling, interchange._

The exact match selector is named `:string`.
Copy link
Member

Choose a reason for hiding this comment

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

For selection, I think this is confusing. The alternative below of exact seems much clearer. I could also live with equals.

@aphillips
Copy link
Member Author

In the 2023-12-18 call there was a consensus to merge this as "proposed" for further consideration in the 2024-01-08 call. If you have additional proposals, please make a new PR.

@aphillips aphillips merged commit 5d5a425 into main Dec 18, 2023
@aphillips aphillips deleted the aphillips-exact-match-selector-options branch December 18, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Issue pertains to the default function set normative Issue affects normative text in the specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants