On 12/28/2010 5:05 PM, Joel Falcou wrote: > Here i smy use case. I guess Eric answer will be "do this at > evaluation time"
Do this at evaluation time. Just kidding. > but let's I have some array/matrix DSEL going on. I > want to test if two expression containing said matrix has compatible > size before creating a proto ast node. > > e.g if a,b are matrices, a + b should assert if size(a) != size(b) > (in the matlab meaning of size). > > Now i can do the check when evaluating the expression before trying > to assign it BUT it irks me that the assert triggers inside the > matrix expression evaluator instead of at the line said + was wrongly > called. > > Could we have some way to specify code to call before returning the > a new operator AST node, shoudl I overload operators myself ? Should > I stick with the "assert in eval" policy and try to come up with way > to tell the user which operators faile din which expression, did I > miss the obvious ? You missed the "Generator" parameter to proto::domain. It's a unary function object that accepts all new proto expressions and does something to it. That something can include asserting if matrix/vector sizes don't match. HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com _______________________________________________ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto