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

Deep-equal comparisons without errors #381

Closed
ndw opened this issue Feb 28, 2023 · 3 comments
Closed

Deep-equal comparisons without errors #381

ndw opened this issue Feb 28, 2023 · 3 comments
Labels
Editorial Minor typos, wording clarifications, example fixes, etc. XQFO An issue related to Functions and Operators

Comments

@ndw
Copy link
Contributor

ndw commented Feb 28, 2023

At meeting 024 where PR #320 was accepted, there remained an open question of how to deal with errors.

On the one hand, in order for fn:deep-equal to be most easily used as a comparison function in the many contexts where a comparison function is required, it would be best if it simply returned false() rather than raising an error when incomparably items are encountered.

On the other hand, making "return false()" the default will mean that it is possible to construct items that are not equal to themselves, which will certainly violate the expectations of some users.

This conflict needs to be resolved somehow.

@ChristianGruen ChristianGruen added XQFO An issue related to Functions and Operators Editorial Minor typos, wording clarifications, example fixes, etc. labels Mar 1, 2023
@ChristianGruen
Copy link
Contributor

If we allow fn:deep-equal to compare function items, that would change the behavior of the function and lose backwards-compatibility. Can we do that at all? I guess it could be viable, as the old result was an error, and we are basically making the function more powerful. What do others think?

If we can do it, my preference would be to drop false-on-error and always return true/false once we have resolved in #333 how we want to compare function items.

@michaelhkay
Copy link
Contributor

michaelhkay commented Mar 1, 2023

Yes, my preference is to

(a) drop the error condition and the false-on-error option

(b) for comparing function items, adopt the rules in F&O §1.8.4, which basically say that the result is false unless the processor is "able to determine" that the two functions always have the same effect, which probably means in practice that a processor will only return true if the two functions are internally implemented by pointers to the same object in memory. The best thing about this rule is that deep-equal($x, $x) is allowed to return true without even looking first to see whether $x contains any functions.

A change whereby something that used to throw an error now returns a non-error result is not generally considered to be an incompatibility.

@michaelhkay
Copy link
Contributor

PR #525 has resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Editorial Minor typos, wording clarifications, example fixes, etc. XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

3 participants