Hi Ondrej,

> > I'm looking into the AssocOp code to implement the functions that will
> > flatten a longer expression, and I have a question. Why does SymPy use
> > this structure everywhere:
>
> > class Basic(...):
> >    is_Atom = False
>
> > class AssocOp(...):
> >   [EMAIL PROTECTED]
> >    def identity(cls):
> >        if cls is Mul: return S.One
>
> ^^ do you mean why it references the Mul class here? Or is your
> question about something else?

Let me clarify what I am asking. Take the example of AssocOp. Mul is a
derived class from AssocOp, yet the AssocOp "identity" method asks if
it is an instance of Mul. It seems to me that a base class shouldn't
have knowledge about its derived classes. Derived classes, on the
other hand, should know what their base classes are.

Similarly for classes derived from Basic. Atom is derived from Basic,
yet Basic has a property called "is_Atom". This class entanglement
seems a bit cumbersome to me. Since I haven't read "Design Patterns",
I was just wondering if there's a proverbial method to this
madness :).

Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to