Re: Re: Function memoization
Dimitre Novatchev <[email protected]>
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Message-ID | <[email protected]> |
Hi Florent, I sense a great deal of confusion in your message -- let's move the discussion off-list in case you have further questions. The problem of memoising impure functions is in the fact that memoisation strips the impure function of its (every time different) side effect and typically the side effect is what was desired by the authors of the function. Also, by not recognising sequence arguments as the same, there will be the very confusing behaviour that sometimes side effects show from evaluating an impure function, and sometimes there are no side effects -- this is exactly what we are talking about. So we need just to say: do not try to memoise an impure function -- this is immoral and the results will be unpredictable. Cheers, Dimitre --- Florent Georges <[email protected]> wrote: > Dimitre Novatchev wrote: > > Dimitre, > > Thanks a lot for your clear explanations. > > > The *only* type of an xsl:function that can produce different > > results when called twice with the same arguments is one that > > creates nodes -- with instructions such as xsl:copy, > > xsl:copy-of, xsl:element, xsl:attribute, ..., etc. > > > Every time such a function is evaluated it will produce a new > > (different!) node or sequence of nodes. > > So the result can be different only by its identity, not by its > value, right? If it is, I think your warning below is a little too > strong. Warning that identity of the result can not be relied on could > be enough, isn't it? Because when the memoisation is supported by an > implementation, the results will be required to be identical, but when > memoisation is not supported the results will never be identical (by > construction). > > Put in "simple words": "you can't rely on the 'is' operator for such > results". And I guess identity tests are not usual on such results; I > guess they are more often used on nodes in input trees (it is just a > guess). > > > "Memoisation of an impure function (one that has side effects) will > > generally have unpredictable results that conflict the semantics of > > such a > > function. Doing so is illegal. As function impurity could be > > difficult to > > ascertain, an implementation is not required to issue an error > > message for > > specifying memoisation for an impure function and the sole > > responsibility > > of doing so remains with the xslt programmer". > > Because we are talking about memoisation, it seems natural that the > identity can't be trusted, isn't it? > > Maybe I missed something? > > Thanks for the explanation. > > Regards, > > --drkm > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ___________________________________________________________________________ > > Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son > interface révolutionnaire. > http://fr.mail.yahoo.com > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com