On Friday, July 4, 2014 2:20:07 AM UTC+2, Matthew wrote: > > This is easier if we stop automatic evaluation on classes. I usually > propose that the classes like `Add` do no construction logic while paired > functions like `add` take on all of the construction logic. Then you can > create patterns like Add(oo, 'x') without fear that they will change to > something else. > > That is an interesting idea. Maybe no SymPy object should overload the __new__ constructor?
Mathematica uses attributes to define some automatic evaluations, for example "Flat", have a look at this example: In[1]:= f[a, b, f[c, d, e]] Out[1]= f[a, b, f[c, d, e]] In[2]:= SetAttributes[f, Flat] In[3]:= f[a, b, f[c, d, e]] Out[3]= f[a, b, c, d, e] This could be emulated by putting a static variable *flat* in *Expr*: class Expr(Basic): ... flat = False class Add(...): ... flat = True Whenever flat is True, flattening automatically happens upon construction. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/be1ffa00-fe05-4f85-beeb-ba245ea4d3a6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.