ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> exslt
exslt
[exslt] Re: Function memoization
by Dimitre Novatchev other posts by this author
Jul 10 2006 4:42PM messages near this date
Re: [exslt] missing copyrights and licensing information | Re: [exslt] Re: Function memoization
& XSLT Subject: Re: Function memoization 
To: exslt@[...].com 

>  If the function is called again with the same values for the arguments,
>  it MUST return the remembered result.
>  It MUST NOT re-execute the function body, as this can cause different
>  results in some cases.

We must define well what "the same values for the arguments" means.

It is impractical to remember and compare long sequences -- this may
require 
excessive amounts of memory and may lead to slower execution than without 
any memoisation.

I have discussed this problem with Michael Kay before. A compromise we 
agreed upon was not to memorize every sequence-argument but just the ID of

the sequence.

Using this approach, if we pass to the function the same sequence (having 
the same ID) allong with all other arguments' values being as on the same 
previous function evaluation, then the function body will not be executed 
and the stored result will be returned.

However, if a sequence is passed with a different ID, the function body
will 
be executed -- although the values of the items of the passed sequence may

be identical to the values of the items of a sequence that was previuosly 
passed as that argument, but has a different ID.

Cheers,
Dimitre Novatchev


"Colin Paul Adams" <colin@[...].uk>  wrote in message 
news:m3wtavkyxe.fsf_-_@[...]..
> >>>>> "James" == James Fuller <jim.fuller@[...].uk> writes:
> 
>     >> modified form, a proposal that Dimitre Novatchev originally
>     >> requested for memomizing xsl:functions.
> 
>     >> The modification being that the memoization reqest be an
>     >> extension instruction actually present within the xsl:function
>     >> concerned (this seems to me necessary to preserve compliance
>     >> with the specifications - user-defined data elements and
>     >> extension attributes may not cause a different final result
>     >> tree to be produced, and, in some cases, memoization of a
>     >> function will do just that).
> 
> 
>     James> I am interested in such a function as well.
> 
>  OK. I shall try to define it's semantics:
> 
>  func:memoize will be an extension instruction. No attributes. Only 
>  permitted contents is an xsl:fallback child.
> 
>  The instruction must be an immediate child of an xsl:function or
>  func:function.
>  Good style suggests placing this immediately after the xsl:params, or
>  at the very end of the function body - but I do not think we need
>  mandate any such placement (except xsl:param must come first, as now).
> 
>  An XSLT processor that supports func:memoize shall remember the
>  results of any calls to functions marked with a call to
>  func:memoize. If the function is called again with the same values for
the 
>  arguments,
>  it MUST return the remembered result.
>  It MUST NOT re-execute the function body, as this can cause different
>  results in some cases.
> 
> 
>  -- 
>  Colin Adams
>  Preston Lancashire 





Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
exslt mailing list
list@[...].org
http://www.exslt.org/list
Thread:
Dimitre Novatchev
Colin Paul Adams
Dimitre Novatchev
Dimitre Novatchev
Colin Paul Adams
Florent Georges
James Fuller
Colin Paul Adams
Florent Georges
Dimitre Novatchev
Florent Georges
Dimitre Novatchev
Florent Georges
Dimitre Novatchev
Colin Paul Adams
Frans Englich
Florent Georges

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved