Re: Reference and First-Class Function

John Snelson <[email protected]> Fri, 19 Dec 2008 17:40:30 +0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <[email protected]>
Vladimir Nesterovsky wrote:
>> o Higher order function support would be good to have.
>> o Sequence references would be good to have.
>> o Since HOF closures look a lot like sequence references, if we're 
>> going to have both we should implement one in terms of the other.
> 
> I think it's rather untrivial to implement refereneces in terms
> of higher order functions through extension functions and extension 
> objects only.
> 
> If there were inline functions that would be a copletely different thing.
> 
> If I'm wrong, can you please show an example of an expression using such 
> extensions.

Here's how I'd declare it in XQuery without using inline functions:

declare function ex:identity($x)
{
   $x
};

declare function ex:ref($x)
{
   ex:partial-apply(ex:function("ex:identity", 1), $x)
};

declare function ex:deref($r)
{
   ex:call($r)
};

John

-- 
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:            http://oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net