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

Getting the value of the new identity-(DM)property of a function. fn:function-identity #1798

Open
dnovatchev opened this issue Feb 12, 2025 · 1 comment
Labels
Feature A change that introduces a new feature PR Pending A PR has been raised to resolve this issue XDM An issue related to the XPath Data Model XPath An issue related to XPath XQFO An issue related to Functions and Operators

Comments

@dnovatchev
Copy link
Contributor

dnovatchev commented Feb 12, 2025

The current set of Functions on Functions: at (https://qt4cg.org/specifications/xpath-functions-40/Overview.html#functions-on-functions) was recently updated with a new function to produce all annotations for a given function: fn:function-annotations.
However we are still missing the ability to reference another important, newly-added property of a function: the function identity: in DM and in XPath.


fn:function-identity

Summary
Returns the identity of the function item.

Signature

fn:function-identity(
  $function as fn(*)
) as xs:string

Properties
This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Notes

  1. This function can be useful in any scenario, where the evaluation of a function call requires repeated evaluation of this same, or other functions. Often in such cases, the algorithm needs access to a general structure, containing the cached results of executing possibly many different functions applied on specific arguments-tuples.
    What unique key is needed under which to group all invocations of a specific function and then the mapping between their function-call arguments and the result of the call? Remarkably, the identity of a function fits exactly the requirements (uniqueness / one per function) for such a key.
    As we already have a function-identity property in the Data Model for each function-item, it is straightforward to provide this identity, and the fn:function-identity does exactly that.
  2. The function identity, by definition, is generated upon the creation of a function and has meaning throughout of the life of that function. It is not meaningful to store this value across different executions, because the identity given to a function in execution1 will generally be different from the identity, given to it in execution2. However, the definitions of system functions (functions defined in the specifications under the system namespaces - with standard prefixes: xs, fn, map, array, math, err, output) can be assigned permanent identities in the official Specs documents, requiring every implementation to use exactly this published identity value for the official, system functions, thus achieving efficiency and convenience during debugging.
  3. The function identity, being a string, can be used as a key in a map, thus making it possible to map a particular function to a sequence of items. It becomes possible to allow function items as map-keys by extending the definition of same-keys with: "If both keys are function items: $f1 and $f2, then they are the same if and only if:
    function-identity($f1) eq function-identity($f2)
@dnovatchev dnovatchev added XPath An issue related to XPath XQFO An issue related to Functions and Operators XDM An issue related to the XPath Data Model Feature A change that introduces a new feature PR Pending A PR has been raised to resolve this issue labels Feb 16, 2025
@michaelhkay
Copy link
Contributor

An alternative approach would be to generalize fn:generate-id() so it can be applied to function items - perhaps to all items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A change that introduces a new feature PR Pending A PR has been raised to resolve this issue XDM An issue related to the XPath Data Model XPath An issue related to XPath XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

2 participants