`apply-gen' now ingores arity-overloaded functions
Rationale is provided in `apply-gen.xsl'.master
parent
e392d411fa
commit
31aa7fa111
|
@ -112,6 +112,37 @@
|
|||
</template>
|
||||
|
||||
|
||||
<!--
|
||||
Do not process functions that are overloaded on arity
|
||||
|
||||
There are a couple reasons for this: Firstly, overloading is
|
||||
fundamentally incompatible with partial application, because we are unable
|
||||
to determine when a function is fully applied. Secondly, we would have no
|
||||
choice but to generate functions for every arity that does @emph{not}
|
||||
exist. Together, that would yield a very awkward implementation whereby
|
||||
applying N arguments may apply the target function, but N-1 and N+1 may
|
||||
result in a partial application. That is not acceptable.
|
||||
|
||||
To aid in debugging, a comment is output stating that the function was
|
||||
explicitly ignored.
|
||||
-->
|
||||
<template mode="fgen:create"
|
||||
match="xsl:function[
|
||||
@name = root(.)/xsl:*/xsl:function[
|
||||
not( . is current() )
|
||||
]/@name
|
||||
]"
|
||||
priority="5">
|
||||
<comment>
|
||||
<text>No definition generated for overloaded function `</text>
|
||||
<value-of select="@name" />
|
||||
<text>#</text>
|
||||
<value-of select="count( xsl:param )" />
|
||||
<text>'</text>
|
||||
</comment>
|
||||
</template>
|
||||
|
||||
|
||||
<!--
|
||||
Process function definition
|
||||
-->
|
||||
|
|
|
@ -42,6 +42,17 @@
|
|||
<sequence select="$x - $y" />
|
||||
</function>
|
||||
|
||||
|
||||
<!-- overloaded function, for which we cannot generate anything -->
|
||||
<function name="foo:overloaded">
|
||||
<param name="a" />
|
||||
</function>
|
||||
<function name="foo:overloaded">
|
||||
<param name="a" />
|
||||
<param name="b" />
|
||||
</function>
|
||||
|
||||
|
||||
<!-- large number of arguments to test partial application -->
|
||||
<function name="foo:eight" as="item()+">
|
||||
<param name="arg1" />
|
||||
|
|
|
@ -130,6 +130,27 @@
|
|||
</scenario>
|
||||
|
||||
|
||||
<!-- see SUT for rationale -->
|
||||
<scenario label="given an arity-overloaded function">
|
||||
<context>
|
||||
<xsl:stylesheet>
|
||||
<xsl:function name="foo:overloaded">
|
||||
<xsl:param name="a" />
|
||||
</xsl:function>
|
||||
|
||||
<xsl:function name="foo:overloaded">
|
||||
<xsl:param name="a" />
|
||||
<xsl:param name="b" />
|
||||
</xsl:function>
|
||||
</xsl:stylesheet>
|
||||
</context>
|
||||
|
||||
<expect label="yields no functions of that name"
|
||||
test="not( xsl:stylesheet/xsl:function[
|
||||
@name='foo:overloaded' ] )" />
|
||||
</scenario>
|
||||
|
||||
|
||||
<scenario label="given a stylesheet">
|
||||
<scenario label="with no function elements">
|
||||
<context>
|
||||
|
|
Loading…
Reference in New Issue