Re: [xsl] RE: Designs for XSLT functions

Subject: Re: [xsl] RE: Designs for XSLT functions
From: Joe English <jenglish@xxxxxxxxxxxxx>
Date: Tue, 20 Feb 2001 12:25:29 -0800
Michael Kay wrote:

> > An apply() function (which simply calls another function whose
> > name is decided at runtime) would be easier to use than a
> > general-purpose evaluate() routine though.  Programmatically constructing
> a
> > syntactically valid XPath expression can be tricky.
> >
> > Apply() would likely also be easier to implement and more efficient
> > than evaluate().
> Ease of use? Programmers using ODBC or JDBC are very used to constructing
> SQL statements at run-time, and rarely complain.

And Tcl programmers routinely complain about "quoting hell"
whenever they use 'eval'.  This has the potential to be just as 
bad with XPath and XSLT, since there's already another level of 
quoting going in inside XML attribute values.

> Ease of implementation? It's easier to implement one construct than two, and
> if one is a subset of the functionality of the other, I'd rather implement
> the more general one.
> Efficiency? Show me the evidence! It's easy to use the same kind of tricks
> as one uses for format-number(), caching the format patterns that have been
> used in the past so they don't have to be parsed again.

I'll defer to your expertise here, as you've implemented an XSLT
processor and I never finished mine, but I will say that it would
indeed be much easier to implement 'apply' than 'eval' in the
framework I was using.

It's not just a matter of parsing dynamically constructed expressions
at run-time, either.  The presence of 'eval' means you have to carry
around a lot more information than you would have to otherwise.
For example, without 'eval', it's possible to statically resolve all
variable references.  With 'eval', the implementation has to maintain
a dictionary of variable bindings at run-time, just in case an 'eval'ed
string references an in-scope variable.  An XSLT compiler would
have to include a complete XPATH interpreter in its runtime system!
Granted, 'apply' has some of the same problems, but they're much more 
pronounced with 'eval'.

Other examples, perhaps not relevant, are Tcl and R5RS Scheme.
Some Scheme implementations were able to implement 'eval' without
any difficulty, for others - notably the highly-optimized ones -
it took considerable effort.  'eval' is a central feature of Tcl,
but implementing it efficiently in 8.x was decidedly non-trivial.

OTOH, this probably doesn't apply to XPATH/XSLT.

--Joe English


 XSL-List info and archive:

Current Thread