Dear Kilian,

From inside some local space you can not change the state of some datum in the global space. So, putting your data structure inside your script may already solve your problem.

When using memoization to write complex CSPs in a modular way, you may instead want to keep your data outside the script. For example, you may have a function that returns a constrained variable which is not explicitly stored in your data structure but only returned by this function. When the function is called multiple times with the same argument, it should returned the same (memoized) constrained variable.

For this purpose, I wrote a little memoization module which makes use of nested stateless data (based on record constraints). Adding and accessing an entry is stateless. The only stateful operation supported is to wipe the whole memoization table. So, you can call some memoized function in the CSP and wipe the table in the top-level. The only problem of this module is that adding/accessing an entry in the table needs linear time in the worst case (depending on the number of entries in the table) instead of constant time (as accessing a record usually does), because RecordC only defines RecordC.reflectArity (i.e. there is no RecordC.reflect.hasFeature).

Attached are two modules, one defining the stateless data structure, the other defining means to memoize functions (the HTML doc of the latter suggests that this module depends on my App Strasheela, which is not the case anymore, see doc in the code iinstead).

Best,
Torsten

Attachment: Memoize.tgz
Description: GNU Zip compressed data

Attachment: MultiRecord.tgz
Description: GNU Zip compressed data




On 04.05.2006, at 12:17, Kilian Sprotte wrote:
Hi,

I am rather an Oz newbie and I am having a little problem with the Space hierarchy. I have written a function that returns some data (a list of FS constants...) to be used in a search script - I have implemented this function using a dictionary for memoization, because I was hoping to access the desired data inside the search script without being forced to precompute it explicitly beforehand. (Since outside the search script, I dont really know what my args to this function are...)

I am getting an error that states I cannot do Dictionary.put from a local Space.

Wanted to ask you, if redesigning this memoized functions as an Active Service using a port would probably solve the problem?

If this is completely wrong, I would of course be happy as well to get a hint pointing in any other direction. :)

Thanks,

  Kilian Sprotte



_______________________________________________________________________ __________ mozart-users mailing list [email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users


--
Torsten Anders
Sonic Arts Research Centre • Queen's University Belfast
Frankstr. 49 • D-50996 Köln
Tel: +49-221-3980750
www.torsten-anders.de
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to