From: Noah Stein (noah_at_[hidden])
Date: 2008-03-26 03:00:36
I spent a few hours the other week trying to convert my last matrix-vector
class library over to proto. It implemented expression trees, but Id never
gotten around to adding some features that proto should make much, much
easier to implement such as expression optimization. I figured it would be a
good way to experiment with the library to review. I eventually gave up on
refactoring my class towards proto and instead tried refactoring your
lazy_vector example towards my class. It's raised some questions/points.
I'll illustrate with questions that are based on your lazy_vector example.
1) lazy_vector seemed like it could derive from lazy_vector_expr in CRTP
fashion. I figured your use of std::vector<T> as the terminal type was just
to make initialization easier; however, using CRTP fails to compile. Did I
miss this in the documentation or is it not explicitly mentioned?
2) How can I handle scalar values transparently? My attempts to accept
"v1=v2*5" have failed. I can't get the 5 to implicitly construct into a
scalar_vector type I have defined. I had that working in my old one, but I
can't seem to figure out the correct way of setting that up in proto.
3) My vector class' signature is very simple: template<typename T> class
Vector : VectorExpr<terminal<T> > . The type T contains a number of traits
defining the vector: the type of the elements, the dimension, how the data
is stored. I can't figure out how to specify the terminals in my grammar. In
your example, you use terminal<std::vector<_> > as your terminal. The
std::vector part is unknown to me. That's my point of variation in my vector
concept thus I can't know all the different types that could be used in the
terminal. I tried deriving my storage classes from a common base class;
however, that failed. Is there any way to encode some sort of restriction
in the grammar for this situation? Right now, I'm using _, but that's
clearly not a great solution.
Proto looks very interesting. I was quite excited the first I saw it
mentioned. There seems to be a lot of power there. I just need to figure out
how to use it. You have a lot of documentation, but it seems to be attacking
the problem from the opposite direction I'm approaching from, so it's been a
little slow going. I hate asking questions about something I can investigate
on my own, but I'd like to get far enough along that I can properly review
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.0/1342 - Release Date: 3/25/2008
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk