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

1798 Function fn:function-identity #1801

Merged
merged 9 commits into from
Mar 5, 2025
Merged

Conversation

dnovatchev
Copy link
Contributor

The function fn:identity as already described and discussed in #1798

Copy link
Contributor

@michaelhkay michaelhkay left a comment

Choose a reason for hiding this comment

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

"can be assigned permanent identities in the official documentation, requiring every implementation to use exactly the published identity value for the official, system functions, thus achieving efficiency, uniformity, and a degree of interoperability. - this is the official documentation, so it's inappropriate to include such a statement here. (I suggest saying that for these functions the result of function-identity is the URI-qualified name followed by '#' and the arity.)

@dnovatchev
Copy link
Contributor Author

"can be assigned permanent identities in the official documentation, requiring every implementation to use exactly the published identity value for the official, system functions, thus achieving efficiency, uniformity, and a degree of interoperability. - this is the official documentation, so it's inappropriate to include such a statement here. (I suggest saying that for these functions the result of function-identity is the URI-qualified name followed by '#' and the arity.)

I am deleting this text now.

Defining the exact values for the function identity of the system functions is probably better done separately, and could be discussed.

@michaelhkay
Copy link
Contributor

The Data Model spec, where it introduces function identity, needs to be updated (because it currently implies that function identity cannot be exposed in this kind of way).

The Data Model spec also states that "Function identity is not currently defined for maps and arrays", which leaves an open question as to what the proposed fn:function-identity() returns if supplied with a map or array.

@dnovatchev
Copy link
Contributor Author

The Data Model spec, where it introduces function identity, needs to be updated (because it currently implies that function identity cannot be exposed in this kind of way).

Yes, it only says that the function identity is "abstract"

It probably would be best to update the DM in a separate PR.

The Data Model spec also states that "Function identity is not currently defined for maps and arrays", which leaves an open question as to what the proposed fn:function-identity() returns if supplied with a map or array.

This negative statement simply needs to be removed from the documentation. If the generated identity value is "abstract", then it can be generated the same "abstract" way as done for (non-array and non-map) functions.

We probably should not prescribe what values are generated for non-system functions, we only need a bijective projection of whatever they use internally, into xs:string.

Of course, if I am an implementor, I will probably use GUIDs, but some other implementors may prefer to use something entirely different.

@michaelhkay
Copy link
Contributor

The material question for maps and arrays is whether there are any circumstances in which two expressions that return maps or arrays are guaranteed to return the same map or array. For example, we might want to specify that all evaluations of {} return identical maps; we might also want to extend this to other expressions that return empty maps.

Another significant question is whether function identity is affected by the presence of labels. This applies particularly strongly to maps and arrays: does pin($map) have the same identity as $map? (Note that we have explicitly said that labels have no effect on node identity).

@dnovatchev
Copy link
Contributor Author

The material question for maps and arrays is whether there are any circumstances in which two expressions that return maps or arrays are guaranteed to return the same map or array. For example, we might want to specify that all evaluations of {} return identical maps; we might also want to extend this to other expressions that return empty maps.

It would be good to avoid proving function identity. In some simple/regular cases this can be done, but not in every case.

The ways identity is generated (by the implementation) is orthogonal to this issue - which is the specification of just the function that returns this identity-value to the caller.

This said, and talking beyond the subject of this PR, one obvious way of assigning identity to maps and arrays is producing the hash of their normalized serialization. But again, why not leave this to the specific implementations?

Another significant question is whether function identity is affected by the presence of labels. This applies particularly strongly to maps and arrays: does pin($map) have the same identity as $map? (Note that we have explicitly said that labels have no effect on node identity).

Again, beyond of the coverage of this PR:
I am ignorant of labels/pinned-maps.
I am aware of some cases of functions that are produced from other functions, such as the partial application of a given function. In such cases, using the identity of the original function and concatenating it with an identity of the particular operation upon this function (such as partial application by fixing arg#N with particular value), will be a guarantee that if the same operation is performed on the same function, then the result(_2) of this operation will be given the same identity as the result(_1) of performing this same operation for the first time. Thus regardless of how many different partial applications (fixing the same argument with the same code) we have in our code, they all will be given the same identity.

@michaelhkay
Copy link
Contributor

Fix #1798

@michaelhkay michaelhkay changed the title Function fn:function-identity 1798 Function fn:function-identity Feb 18, 2025
@michaelhkay michaelhkay added XQFO An issue related to Functions and Operators Tests Needed Tests need to be written or merged Feature A change that introduces a new feature labels Feb 18, 2025
@dnovatchev
Copy link
Contributor Author

dnovatchev commented Feb 18, 2025

Fix #1798

And isn't this cryptic?

Sorry, what does this mean?

MHK> It's a magic incantation understood by GitHub to mean that when this PR is merged, issue 1798 can be automatically closed.

@ndw
Copy link
Contributor

ndw commented Mar 5, 2025

At meeting 112, the CG agreed to merge this PR.

@ndw ndw merged commit 38dd876 into qt4cg:master Mar 5, 2025
3 checks passed
@dnovatchev dnovatchev deleted the dn-function_identity branch March 12, 2025 03:38
@michaelhkay michaelhkay added Tests Added Tests have been added to the test suites Completed PR has been applied, tests written and tagged, no further action needed In Saxon 13 The feature is implemented in the Saxon 13 development branch and removed Tests Needed Tests need to be written or merged labels Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Completed PR has been applied, tests written and tagged, no further action needed Feature A change that introduces a new feature In Saxon 13 The feature is implemented in the Saxon 13 development branch Tests Added Tests have been added to the test suites XQFO An issue related to Functions and Operators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants