Re: memo package - persistent memoisation

"Abdallah, Samer" <[email protected]> Fri, 18 Apr 2014 15:27:09 +0000
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 18 Apr 2014, at 16:16, Michael Hendricks <[email protected]>
 wrote:

> Hi Samer.
> 
> On Fri, Apr 18, 2014 at 8:21 AM, Abdallah, Samer <[email protected]> wrote:
> Hello all,
> Inspired by Jan's persistency library, I've release a new package called 'memo'
> for doing memoisation.
> 
> Thanks for releasing this.  I expect to use it in a couple different projects.  It's nice not to manually rewrite this kind of memoization code for each predicate.
>  
>         - should I factor out some of the component functionalities, which at the moment, are
>                 1. type checking
> 
> Yes please.  library(typedef) is a very common interface, it would be great to have a shared open source library that we can all work on together.  I have similar (unreleased) code for type definitions for my "mavis" and "quickcheck" libraries.  I'd gladly recommend library(typedef) if it were an independent pack.

I agree. I was going to bring this up in a separate post - I think it would be great to have
some PlDoc support for type declarations, as I often find myself doing this informally
in module header comments.

> 
> Is there a Git repository for this pack?  I may submit a couple patches.
Not at the moment. I'm a Git virgin. I should get round to it soon.
It's on a site called sound software maintained by the centre for digital
music at Queen Mary where I used to work. You can certainly browse the
site but you have to be registered to modify anything.
	https://code.soundsoftware.ac.uk/projects
Feel free to send me a patch in the meantime.

> 
> 
> As an aside, the pack documentation has the line:
> 
>     ?- sqrt1(-4.0,X). % fails
> 
> Would that give X=nothing rather than failing?  That seems to be the case based on the earlier examples in the documentation.
You're right - there used to be another sqrt predicate in the example to 
illustrate memoisation of failures, but I removed it and forgot to fix the
other bit. Those examples should be
?- sqrt1(16,X).   % leads to type error (16 is not a float)
?- sqrt1(16.0,X). % computes X=just(4.0)
?- sqrt1(16.0,X). % looks up old result, X=just(4.0)
?- sqrt1(-4.0,X). % computes X=nothing
?- sqrt2(9.0,X).  % computes X=3.0 and stores persistently
?- sqrt2(-4.0,X). % records exception and then rethrow is
?- sqrt2(-4.0,X). % rethrows recorded exception
Thanks for your comments!
Samer


> 
> -- 
> Michael

-------------- next part --------------
HTML attachment scrubbed and removed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20140418/14b8146c/attachment.bin>