.............................
Post by Florent Georges2. Postulate existance of references and indirect function calls,
and derive closures from these constructs.
Vladimir,
There is no need to "postulate" the existence of references as they already exist (in all programming languages I am aware of). Do you need to postulate that "water exists"?
We really have and use references in XPath, XSLT and I believe XQuery as a superset of XPath.Any
<xsl:sequence select="someNode"/>
instruction produces a reference to that node, not a copy of it.
We have many statements from Dr. Kay himself, one of the most recent is probably from this September in the thread in xsl-list "Benefits of xsl.sequence" :
http://www.stylusstudio.com/xsllist/200809/post50470.html
"Yes: this is the only way that you can write a function (or indeed a
template) that returns references to existing nodes"
And there are quite some of his statements to this effect through the years (the earliest I have seems to be from 2003).
Another source of statements that we have been using references all the time in XSLT 2.0 are the books of Dr. Kay.
To quote Dr. Kay's book "XSLT 2.0 and XPath 2.0 4th edition Programmer's Reference", ISBN: 978-0-470-19274-0, page 452:
"The <xsl:sequence> instruction ... is the only XSLT instruction (with the exception of <xsl:perform-sort>) that can return references to existing nodes, as distinct from newly constructed nodes."
Identical text is on page 420 of Dr. Kay's book "XSLT 2.0 3rd edition Programmer's Reference" (ISBN: 0-764-56909-0)
So, references do exist in XPath and XSLT, they are held in a variables and returned from functions. The only problem is whenever we want to store them in an XML document or use a reference to a sequence as an atomic item inside another sequence.
There is no problem of defining a "reference" type without closures and the whole attempt to invent references through closures is incorrect and artificial. References were there all the way, we were happily using them without ever complaining that they lacked closures.
References exist and are used in most XSLT 2.0 transformations. We don't need to postulate anything -- just use what we already have in a more formal definition of the "reference" type.
The issue I have raised is that any attempt to define references based on closures ignores the fact that closures are defined using references -- this is a circular definition and it expands infinitely (like infinite recursion) and fails to define anything.
Post by Florent GeorgesThe definition of closure uses references, so it is not what Dr. Kay is speaking
about.
Therefore, it would be correct if Dr. Kay stops calling "closure" the thing he
is talking about, rename it to something else, and most importantly, show how
this "something else" can create a reference out of thin air.
Cheers,
Dimitre
Post by Florent GeorgesPost by Florent GeorgesPost by Dimitre NovatchevOnce again, closures "have references" to external variables.
As I said even in my previous message, a closure contains a
reference.
Or put in another way: if you get closures, you get references.
This statement ignores the fact that the term "reference" is used in the
definition of "closure" I quoted the definition of closure from Wikipedia and
the places where the term "reference" is used.
Post by Florent GeorgesPost by Dimitre NovatchevA closure relies on the concept of reference being already
implemented.
I wouldn't put it like that. Closures does not rely on the feature
of reference being available in the language, even if their
implementation needs to provide that in some way.
A very interesting statement... :) So, we confess of having to use references
... from somewhere...???
Then we deny references existed when we used them...
Then we say: We give you references *for free* !
This made my day, Thank you.
Post by Florent GeorgesAnd as Michael showed us, if you get closures, you get references for
free.
Of course -- as you already have *references* inside the closure!
Dr. Kay did't show anything. He expressed his believes on the topic.
On the other side, I provided quotes to the definition of closure. This is not
my belief, but the oficial definition.
The definition of closure uses references, so it is not what Dr. Kay is speaking
about.
Therefore, it would be correct if Dr. Kay stops calling "closure" the thing he
is talking about, rename it to something else, and most importantly, show how
this "something else" can create a reference out of thin air.
_______________________________________________
exslt mailing list
http://www.exslt.org/list