Generator functions
Added by Anonymous over 14 years ago
Legacy ID: #8351683 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)
I would like to continue with a question about generator functions: http://article.gmane.org/gmane.text.xml.xsl.general.mulberrytech/80053 Previously I've had a negative experience with this kind of functions: [code] <xsl:function name="t:generate" as="xs:integer*"> <xsl:param name="value" as="xs:integer"/> <xsl:sequence select="$value"/> <xsl:sequence select="t:generate($value * 2)"/> </xsl:function> [/code] but now, looking into the source, I've found that a little fix helps: [code] <xsl:function name="t:generate" as="xs:integer*"> <xsl:param name="value" as="xs:integer"/> <xsl:sequence select="$value + 0"/> <xsl:sequence select="t:generate($value * 2)"/> </xsl:function> [/code] This is related to decided evaluation mode: SHARED_APPEND_EXPRESSION or MAKE_CLOSURE. You might want to address this case.
Replies (2)
RE: Generator functions - Added by Anonymous over 14 years ago
Legacy ID: #8351719 Legacy Poster: Michael Kay (mhkay)
Looks like a case of two optimizations fighting for supremacy. It's difficult to make general improvements when this kind of thing happens: optimizations that help one program can often have adverse effects on another.
RE: Generator functions - Added by Anonymous over 14 years ago
Legacy ID: #8360197 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)
I think that there is some inherent problem in taking decision to spool the output looking only at expression. In some cases like with sorting and grouping it's enough but in other cases an expression's consumer would better to decide whether it wants to spool its input before the use.
Please register to reply