apply-gen now ignores nullary functions
parent
935ce312b4
commit
4130b6cf4b
|
@ -73,12 +73,41 @@
|
|||
</template>
|
||||
|
||||
|
||||
<!--
|
||||
Skip nullary functions
|
||||
|
||||
Nullary functions (functions that accept no arguments) are either
|
||||
thunks or are used purely for their side-effects. We cannot
|
||||
generate a definition for them of the same name, because our
|
||||
definitions are nullary; instead, we expect the caller to take
|
||||
caution.
|
||||
|
||||
If a thunk, then the function will always return the same value and
|
||||
it does not matter when processing occurs.
|
||||
|
||||
If used for side-effects, then order of processing may matter, but
|
||||
this is a dangerous assumption in itself, since some implementations
|
||||
may not evaluate the function until its return value is actually used.
|
||||
|
||||
Either way, handle it yourself.
|
||||
-->
|
||||
<template mode="fgen:create"
|
||||
match="xsl:function[ not( xsl:param ) ]"
|
||||
priority="5">
|
||||
<comment>
|
||||
<text>No definition generated for nullary function `</text>
|
||||
<value-of select="@name" />
|
||||
<text>'</text>
|
||||
</comment>
|
||||
</template>
|
||||
|
||||
|
||||
<!--
|
||||
Process function definition
|
||||
-->
|
||||
<template mode="fgen:create"
|
||||
match="xsl:function"
|
||||
priority="5">
|
||||
match="xsl:function[ xsl:param ]"
|
||||
priority="4">
|
||||
<!-- we need to take care with namespacing; let's remove context
|
||||
dependencies and simply specify the full namespace URI -->
|
||||
<variable name="name-resolv"
|
||||
|
|
|
@ -52,6 +52,23 @@
|
|||
context="xsl:stylesheet/xsl:function/*">
|
||||
<foo:bar />
|
||||
</expect>
|
||||
|
||||
|
||||
<!-- if a function is nullary, then it is either a thunk or used for
|
||||
its side-effects; we expect the user to take appropriate
|
||||
caution -->
|
||||
<scenario label="given a nullary function">
|
||||
<context>
|
||||
<xsl:stylesheet>
|
||||
<xsl:function name="foo:bar">
|
||||
<foo:thunk />
|
||||
</xsl:function>
|
||||
</xsl:stylesheet>
|
||||
</context>
|
||||
|
||||
<!-- generating one would conflict, of couse -->
|
||||
<expect label="does not generate a function"
|
||||
test="not( xsl:stylesheet/xsl:function )" />
|
||||
</scenario>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue