#9 user-defined closure() function


Hi Michael,

this is the patch that implements user-defined closure()
functions. For clarity I have this decoupled from the
previous patch that contains the special-form / deferred
argument evaluation for extension functions. So, this
patch depends on the previous patch.

The attached ZIP file contains:

closure-only-for-saxon8.1.1.diff -- the patch
Functions.java -- a closure() extension function
demo/closure.xsl -- an example
demo/ClosureTestCounter.java -- a side-effect function
for the example

The demo is run simply on any input (e.g., on itself)

saxon8 closure.xsl closure.xsl

the point of the demo is to show how database inserts
and unique id generation would be deferred up until a
foreign key is required. In this example, a parent id is
only created if we actually insert a child that would refer
to the parent id. The output says what the id attributes
should be.

Implementing this required changes to ExpressionTool
eagerEvaluate and to Closure itself. Please look these
over, IMO they work fine. But this territory is a bit
obscure to me so I might be wrong. The problem with
your code seems to be that the closures are evaluated
when the argument is assigned to the variable or passed
as parameter, which is too early. It should be evaluated
only if the value is actually used. My patch seems to
accomplish this.

Please consider if you might adopt these few changes to
the core if at all possible. You don't need to actually
supply the closure() extension if you don't want to, but
the changes to ExpressionTool and Closure itself would
be highly appreciated.



  • Gunther Schadow

    Gunther Schadow - 2004-11-11

    Logged In: YES

    BTW: this is against saxon-8.1.1 of course.



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks