On 01/06/2014 07:25 AM, Ole Svensson wrote:
> Hi,
> for my vector expression DSEL I would like to be able to write multi 
> assignment expressions like
> y = x = 3.0 * z;
> that effectively translate to 
> for(i=0; i<n; ++i) {
>    y[i] = x[i] = 3.0 * z[i];
> }
> Currently, my proto-fied vector class has an operator=() that calls the 
> respective context to evaluate the RHS of an assignment operation. With multi 
> assignment expressions, I obviously have to include the assignment operator 
> into my grammar. If I do this, how can I execute a context when I just write 
> "y = x = 3.0 * z;"?
> Thank you very much!

Your chosen syntax is a little problematic because for any given
assignment operation, you can't tell statically if it's the left-most
(and should trigger evaluation) or not. One possibility would be to have
assignment return a temporary object, and have the evaluation happen in
the destructor. I don't encourage doing non-trivial work in a destructor
however. Special care would be needed to keep exceptions from leaking out.

I recommend finding a different syntax.


proto mailing list

Reply via email to