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

fn:compare: Support for arbitrary atomic types #893

Closed
ChristianGruen opened this issue Dec 11, 2023 · 3 comments
Closed

fn:compare: Support for arbitrary atomic types #893

ChristianGruen opened this issue Dec 11, 2023 · 3 comments
Labels
Enhancement A change or improvement to an existing feature XQFO An issue related to Functions and Operators

Comments

@ChristianGruen
Copy link
Contributor

Inspired by #866:

We should extend fn:compare to support arbitrary atomic types. The comparison rules…

  • would be unchanged for strings,
  • would rely on fn:numeric-compare for numbers, and
  • would rely on the existing op: functions for the remaining types.

For example, the rule for dates would be:

  • 0 is returned if op:date-equal(A, B) is true,
  • -1 is returned if op:date-less-than(A, B) is true,
  • 1 is returned otherwise.

Some types will be rejected (xs:duration, xs:QName, xs:NOTATION, Gregorian types).

In addition, I would vote for making fn:numeric-compare and fn:atomic-equal private. I don’t see a benefit to expose them; I rather expect people to be confused.

@ChristianGruen ChristianGruen added XQFO An issue related to Functions and Operators Enhancement A change or improvement to an existing feature labels Dec 11, 2023
@michaelhkay
Copy link
Contributor

We chose to expose fn:atomic-equal because it was useful as a callback to functions like fn:for-each-pair() and subsequence-starts-with() and because the alternatives, like count(distinct-values($a, $b)) = 1 are horrible.

@ChristianGruen
Copy link
Contributor Author

We chose to expose fn:atomic-equal because it was useful as a callback to functions like fn:for-each-pair() and subsequence-starts-with() and because the alternatives, like count(distinct-values($a, $b)) = 1 are horrible.

I’d probably have written op('=') or fn:deep-equal#2.

But maybe it's good to motivate people to learn more about the internals of the language this way, and to give experts direct access to it.

ChristianGruen added a commit to ChristianGruen/qtspecs that referenced this issue Dec 17, 2023
ChristianGruen added a commit to ChristianGruen/qtspecs that referenced this issue Jan 2, 2024
ChristianGruen added a commit to ChristianGruen/qtspecs that referenced this issue Jan 2, 2024
@michaelhkay michaelhkay added the PR Pending A PR has been raised to resolve this issue label Jan 3, 2024
@ChristianGruen
Copy link
Contributor Author

Accepted and merged (#909).

ChristianGruen added a commit to qt4cg/qt4tests that referenced this issue Jan 16, 2024
@ChristianGruen ChristianGruen removed the PR Pending A PR has been raised to resolve this issue label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement A change or improvement to an existing feature XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

2 participants