Boost logo

Boost :

Subject: Re: [boost] Interest check: memoization
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-27 02:16:54


----- Original Message -----
From: "James Porter" <porterj_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, January 26, 2009 11:55 PM
Subject: Re: [boost] Interest check: memoization

> If you are interested in looking at the new code, I have updated source
> available here: http://www.teamboxel.com/misc/memoizer-0.2.tar.gz .
> There's obviously a lot of work left to do, but hopefully this will help
> resolve some of your questions regarding function objects.

Hi,

IMO the main issue is that we need to declare a variable, and in order to share this variable we need to either use a global variable or pass it as parameter to the inner functions. What do you think about defining a singleton type avoiding the need of this variable declaration, as do Boost.Flyweith?

what about adding a _singleton variant

  typedef memoizer_singleton<doit> doit_memo;

and use directly the type doit_memo as follows

    doit_memo(5.0,7);

Or

class factorial : public recursive_memoizer_singleton<factorial,int(int)>{
public:
 int call(int n) { if(n<=1) return 1; else return n*memo(n-1); }
};

and use

    factorial(5); // 5!

In this way memoizer will be a generalization of the Flyweith. Of course this do not precludes to provide the non_singleton versions.

Thanks,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk