Skip to content

Commit

Permalink
Add optional names to typed function types
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Jan 13, 2025
1 parent bf9f234 commit 30d5f67
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
11 changes: 10 additions & 1 deletion specifications/grammar-40/xpath-grammar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2753,12 +2753,21 @@ ErrorVal ::= "$" VarName
</g:choice>
<g:string>(</g:string>
<g:zeroOrMore separator=",">
<g:ref name="SequenceType"/>
<g:ref name="TypedFunctionParam"/>
</g:zeroOrMore>
<g:string>)</g:string>
<g:string>as</g:string>
<g:ref name="SequenceType"/>
</g:production>

<g:production name="TypedFunctionParam" if="xpath40 xquery40 xslt40-patterns">
<g:optional>
<g:string>$</g:string>
<g:ref name="EQName"/>
<g:string>as</g:string>
</g:optional>
<g:ref name="SequenceType"/>
</g:production>

<g:production name="MapType" if="xpath40 xquery40 xslt40-patterns">
<g:choice>
Expand Down
22 changes: 19 additions & 3 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5182,13 +5182,18 @@ name.</p>
<term>FunctionTest</term>, <term>ArrayTest</term>,
<term>MapTest</term>, and <term>RecordTest</term>, with no
change in meaning.</change>
<change issue="1136" date="2025-01-12">
Parameter names may be included in a function signature; they are purely
documentary.
</change>
</changes>

<scrap>
<head/>
<prodrecap id="FunctionType" ref="FunctionType"/>
<prodrecap id="AnyFunctionType" ref="AnyFunctionType"/>
<prodrecap id="TypedFunctionType" ref="TypedFunctionType"/>
<prodrecap id="TypedFunctionParam" ref="TypedFunctionParam"/>
</scrap>


Expand All @@ -5210,9 +5215,19 @@ name.</p>

<note><p>The keywords <code>function</code> and <code>fn</code> are synonymous.</p></note>

<p>If parameter names are included in a <nt def="TypedFunctionType">TypedFunctionType</nt>,
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
<code>function($x as node()) as xs:string</code> designates exactly the same type
as <code>function(node()) as xs:string</code>.</p>

<p>Any parameter names that are supplied must be distinct
<errorref spec="XQ" class="ST" code="0039"/>.</p>

<p diff="add" at="issue730">In addition, a <nt def="TypedFunctionType">TypedFunctionType</nt>
may match certain maps and arrays, as described in <specref ref="id-map-test"/> and
<p diff="add" at="issue730">A <nt def="TypedFunctionType">TypedFunctionType</nt>
may also match certain maps and arrays, as described in <specref ref="id-map-test"/> and
<specref ref="id-array-test"/></p>


Expand All @@ -5239,7 +5254,8 @@ name.</p>
def="dt-function-item"
>function item</termref> with the function signature <code>function(xs:int, xs:int) as xs:int</code>.
</p>
<note><p>This can also be written <code>fn(xs:int, xs:int) as xs:int</code>.</p></note>
<note><p>The same type might also be written
<code>fn($x as xs:int, $y as xs:int) as xs:int</code>.</p></note>
</item>
<item role="xquery">
<p>
Expand Down

0 comments on commit 30d5f67

Please sign in to comment.