Re: Extension candidates

"Michael Kay" <[email protected]> Mon, 15 Dec 2008 09:48:54 -0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <2FB76570DE00420B93CC5B90E792CEAE@Sealion>
> 
>   That brings the question: what would be the type of a 
> function?  If I am right, it would be a new specialized kind 
> of item (as nodes are). 

John Snelson did a lot of work on this (with some input from me). Yes, we
had function() as a third kind of item, and then we had a type hierarchy so
that for example function(int)->NCName was a subtype of
function(int)->string. Obviously it's very open-ended how far you go down
this route, and when we're doing it as an extension to the language, rather
than a proposal to extend its core, we need to be less ambitious.

But the basic things you need to consider are:

(a) creating a function value from a named function defined statically in
the query or stylesheet

(b) creating an anonymous function, e.g. through some kind of
lambda-expression

(c) syntax for invoking a function with arguments, e.g. call(f, arg0, arg1,
...)

For the current extension in Saxon I just decided not to do (b), and the
facility is still useful.

Extension types in Saxon (like the type of the result of saxon:function()),
are in fact subtypes of xs:anyAtomic rather than being a third kind of item.
That's largely a matter of implementation convenience, but it simplifies a
lot of the rules.

Michael Kay
http://www.saxonica.com/