From 30d5f675c84e0c8911c70acf689f2aa49d7d11b4 Mon Sep 17 00:00:00 2001
From: Michael Kay
Date: Mon, 13 Jan 2025 00:06:07 +0000
Subject: [PATCH] Add optional names to typed function types
---
specifications/grammar-40/xpath-grammar.xml | 11 +++++++++-
specifications/xquery-40/src/expressions.xml | 22 +++++++++++++++++---
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/specifications/grammar-40/xpath-grammar.xml b/specifications/grammar-40/xpath-grammar.xml
index a44c2aa95..e88501e8c 100644
--- a/specifications/grammar-40/xpath-grammar.xml
+++ b/specifications/grammar-40/xpath-grammar.xml
@@ -2753,12 +2753,21 @@ ErrorVal ::= "$" VarName
(
-
+
)
as
+
+
+
+ $
+
+ as
+
+
+
diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml
index dd0bfe35e..f5b2f84d8 100644
--- a/specifications/xquery-40/src/expressions.xml
+++ b/specifications/xquery-40/src/expressions.xml
@@ -5182,6 +5182,10 @@ name.
FunctionTest, ArrayTest,
MapTest, and RecordTest, with no
change in meaning.
+
+ Parameter names may be included in a function signature; they are purely
+ documentary.
+
@@ -5189,6 +5193,7 @@ name.
+
@@ -5210,9 +5215,19 @@ name.
The keywords function
and fn
are synonymous.
+ If parameter names are included in a TypedFunctionType,
+ they are purely documentary and have no semantic effect. In particular, they
+ play no part in deciding whether a particular function item matches the
+ function type, and they never appear as keywords in function calls.
+ For example the construct
+ function($x as node()) as xs:string
designates exactly the same type
+ as function(node()) as xs:string
.
+
+ Any parameter names that are supplied must be distinct
+ .
- In addition, a TypedFunctionType
- may match certain maps and arrays, as described in and
+
A TypedFunctionType
+ may also match certain maps and arrays, as described in and
@@ -5239,7 +5254,8 @@ name.
def="dt-function-item"
>function item with the function signature function(xs:int, xs:int) as xs:int
.
- This can also be written fn(xs:int, xs:int) as xs:int
.
+ The same type might also be written
+ fn($x as xs:int, $y as xs:int) as xs:int
.
-