|
Boost : |
From: Dean Michael C. Berris (dmberris_at_[hidden])
Date: 2008-05-19 00:42:09
Hi everyone,
I've recently been contemplating on using a lot more of Phoenix (now
that Phoenix 2 seems to be coming out soon) in the work I do, and I find
myself looking at being able to make some things "lazy".
Primarily, I'm interested at building lazy containers or lazy result
sets where you have data bound with a lazy function that only gets
evaluated when needed -- or a container that gets populated as
necessary.
For example, I want to build a mapping between an int and derived data
from a database -- instead of having to query the database for all the
elements of the map and building the map eagerly/greedily, I'd like to
be able to lazily just fetch the required data for every element I
access in the map. The function that "generates" the elements of the map
will have to take care of whatever caching it needs to do, but I guess
that should give enough insight into the kind of thing I'd like to
accomplish.
Another example would be a container which seemingly contains the
fibonacci sequence up to some limit, but doesn't actually compute the
Nth fibonacci number unless it's requested.
Right now, I see that Phoenix 2 allows for traversing and applying STL
algorithms "lazily" but I don't see a facility for creating "lazy
containers" or "lazy ranges". I think I'm looking for something similar
to the transform_iterator in Boost.Iterators only extended to be
containers or better terms would be "result sets".
Does anybody know of a way to achieve this using the current Phoenix 2
implementation in Boost.Trunk?
If not, is there interest in such functionality?
Thanks in advance!
-- Dean Michael Berris Software Engineer, Friendster, Inc.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk