Re: Reference and First-Class Function

"Michael Kay" <[email protected]> Sat, 20 Dec 2008 10:15:26 -0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <7081AF524C134272AD71110C71592B88@Sealion>
>This is a circular definition -- a reference is supposed to be implemented
by something that relies on reference  itself.
> =

> So in this case the concept of reference is not layered on =

> top of=A0the concept of HOF.
> =


No, it's not circular. If you have function closures, you get references for
free.

If I can create functions dynamically:

   let $x :=3D (<a>abcd</a>, <b>pqrs</b>)
   let $ref :=3D new function()->node() {$x}

Then $ref is for all practical purposes a reference to the node-sequence $x.
I can wrap this in some syntactic sugar to create functions ref() and
deref(), but I don't need to add any more concepts. There is no conceptual
difference between a reference to a value and a zero-argument function whose
result is that value: and we shouldn't invent two new concepts if one of
them entirely subsumes the other.

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

     =