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

[XPath] %variadic("sequence") does not allow specifying some argument values in the variadic sequence, and in one case even not the variadic sequence itself #25

Closed
dnovatchev opened this issue Dec 17, 2020 · 1 comment
Labels
Enhancement A change or improvement to an existing feature XPath An issue related to XPath

Comments

@dnovatchev
Copy link
Contributor

The current specification for sequence variadic functions (at: https://qt4cg.org/branch/master/xquery-40/xpath-40-diff.html#id-static-functions) has the following issues:

  1. An empty sequence cannot be specified into the sequence of variadic arguments
  2. Even the last (sequence) argument that is supposed to contain the variadic arguments "disappears" when no variadic argument is specified on the function call

This results in difficulties to describe, explain and implement such sequence-variadic functions, and in inability to provide any argument value (like the empty sequence) within the last, sequence argument.

Proposed improvement, which doesn't have the above problems:

Use array-variadic functions instead of sequence-variadic:

%variadic("array") indicates that the function is array-variadic. An array-variadic function declares one or more parameters, of which the last must be an array. If the declaration includes N parameters, then a call on the function may supply N-1 or more arguments. However, the effective call always consists of N arguments, the first N-1 of which are the values for the positional parameters of the function, and the Nth argument is an array that contains all provided variadic arguments.

Why an array-variadic function doesn't have the problems 1 and 2 above?

  1. An empty sequence can be specified in the last argument, for example: [1, (), 2]. For example:
    myFun($posArg1, $posArg2, ..., $posArgN_minus_1, [1, (), 2])
  2. When no variadic arguments are supplied, the last argument of the effective function call is still supplied -- it is the empty array. For example: myFun($posArg1, $posArg2, ..., $posArgN_minus_1, [])
@dnovatchev dnovatchev changed the title %variadic("sequence") does not allow specifying any argument in the variadic sequence, even not the variadic sequence itself %variadic("sequence") does not allow specifying some argument values in the variadic sequence, and in one case even not the variadic sequence itself Dec 17, 2020
@dnovatchev dnovatchev changed the title %variadic("sequence") does not allow specifying some argument values in the variadic sequence, and in one case even not the variadic sequence itself [XPath]%variadic("sequence") does not allow specifying some argument values in the variadic sequence, and in one case even not the variadic sequence itself Nov 23, 2021
@rhdunn rhdunn added XPath An issue related to XPath XQuery An issue related to XQuery Enhancement A change or improvement to an existing feature labels Sep 14, 2022
@dnovatchev dnovatchev removed the XQuery An issue related to XQuery label Sep 22, 2022
@dnovatchev dnovatchev changed the title [XPath]%variadic("sequence") does not allow specifying some argument values in the variadic sequence, and in one case even not the variadic sequence itself [XPath] %variadic("sequence") does not allow specifying some argument values in the variadic sequence, and in one case even not the variadic sequence itself Sep 24, 2022
@michaelhkay
Copy link
Contributor

The previous draft syntax for sequence-variadic functions has been dropped, so this comment is no longer relevant. We are working on a new proposal.

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 XPath An issue related to XPath
Projects
None yet
Development

No branches or pull requests

3 participants