logo       

Re: Fusion-ifying proto parse trees: msg#00000

parsers.spirit.devel

Subject: Re: Fusion-ifying proto parse trees

Joel de Guzman wrote:
Eric Niebler wrote:
Joel de Guzman wrote:
Eric Niebler wrote:

Expression template trees, by their very nature, are going to be linear almost all the time. People write a>>b>>c>>d, not (a>>b)>>(c>>d). And the precedence of >> makes it branch in the wrong way, so we get the worst-case behavior almost all the time. And I can't really think of anything better. :-(

That's an inherent limitation of proto compared to hand coded ET.
In most cases, in many DSELs, you don't care about grouping of
same operators.


Most cases? I disagree. Imagine using proto to build Blitz++ or MTL or the Physical Quantities library or .... Math is a pretty important domain where grouping most certainly does matter. Grouping matters in I/O, too. For example:

std::cout << ("hello" << "world"); // oops!

Don't let the unique properties of the Spirit DSEL bias you. If we are to have a reusable expression template library, it must be general.


In Spirit,

(a>>b)>>(c>>d)

is semantically the same as

a>>b>>c>>d;

and

(a|b)|(c|d)

is the semantically same as

a|b|c|d

With that knowledge, I can collapse/flatten the tree from binary
to n-ary earlier on, giving me a

sequence(a,b,c,d)
alternate(a,b,c,d)

instead of a

sequence(sequence(sequence(a, b), c), d)
alternate(alternate(alternate(a, b), c), d)



I want you to use proto, and I want to make it easy for you to do so. I'm willing to make changes, so long as they don't make proto a less general tool. I guess I still don't understand your requirements, so let's back up. Please tell me again why you want sequences flattened. It would be helpful if you could also tell me why the code I wrote to make proto trees Fusion sequences is insufficient. I'm sure we can figure something out.


--
Eric Niebler
Boost Consulting
www.boost-consulting.com


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise