Boost logo

Boost Users :

Subject: [Boost-users] [Proto?][Phoenix?] : Advice on creating lazy data structures
From: Manjunath Kudlur (keveman_at_[hidden])
Date: 2010-03-29 23:02:48


With Phoenix or lambda-like DSELs implemented with Proto, it is easy
to implement stuff when the expected actual parameters to the lambda
expressions are primitive types. When I want to pass arbitrary types
to the lambda expression and manipulate it in the lambda expression,
things become complex. For example, consider the following function :

struct point {
  float x;
  float y;
};

float sum(point p) {
  return p.x+p.y;
}

If I want to have a lazy version of this function, I cannot simply do
(arg1.x + arg1.y)(p). I have to implement functions that return Proto
or Phoenix expressions and use it in the language. In the above case,
it would look something like (point_get_x_(arg1) +
point_get_y_(arg2))(p). So for every type I want to support in the
DSEL, I have to implement lazy versions of functions to get and set
the type members, or call some methods. In other words, the language
has to be aware of all the data types that can be used with it. I am
looking for some advice on a standard or a generic way for creating
such lazy data structures. Has something like this been done before? I
will be grateful for any pointers and suggestions.

Thanks,
Manjunath


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net