Skip to content

Allow a sequence of function items in dynamic function calls - #2503

Closed
GuntherRademacher wants to merge 1 commit into
BaseXdb:mainfrom
GuntherRademacher:dynamic-function-call
Closed

GuntherRademacher wants to merge 1 commit into
BaseXdb:mainfrom
GuntherRademacher:dynamic-function-call

Conversation

@GuntherRademacher

Copy link
Copy Markdown
Member

These changes add support for PR 1975, i.e. allowing dynamic function calls to operate on a sequence of function items, fixing the corresponding QT4-Tests. Unfortunately there are 3 errors in BaseX-Tests, because tail-call optimization for dynamic function calls does not work any longer:

The approach taken here is to generate in iteration from within the parser. Effectively,

(upper-case#1, lower-case#1)('aBcD')

is translated to

for $fn in (upper-case#1, lower-case#1) return $fn('aBcD')

but there also is special treatment without an interation for the case where the static type indicates exactly one function item.

An alternative approach might be enhancing the DynFuncCall operator to support a sequence of function items, but that has not been investigated yet.

@ChristianGruen

Copy link
Copy Markdown
Member

An alternative approach might be enhancing the DynFuncCall operator to support a sequence of function items, but that has not been investigated yet.

Yes, I assume this will be the best way forward. It will also cover other cases that would otherwise need to be handled by the parser, such as sequences delivered by the arrow expression:

'x' => (substring-before('abxyz', ?), substring-after('abxyz', ?))()

I will have more thoughts on it.

@ChristianGruen

Copy link
Copy Markdown
Member

I close with PR as I believe I have found an alternative solution (6acd7dd) that does not endanger our TCO rewritings, and that will work for other syntax constructs as well.

@ChristianGruen
ChristianGruen deleted the dynamic-function-call branch September 25, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants