On Monday, November 11, 2013 8:52:40 PM UTC+1, Joachim Durchholz wrote:
>
>
> > What about using instead of this an approach closer to C++ templates?
>
> The problem with C++ is that many people do not know C++, and those that
> believe they do sometimes misinterpret the definitions.
> For that reason, it is usually better to stick with Python nomenclature
> and concepts.
>
>
OK, we don't have to use templates as they are defined in C++. It could be
simply a link to an addition/multiplication rules object inside the class.
> I mean, the Add class would always represent a plus sign, for every
> > expression, while its properties are managed by templates,
>
> Here, the question would be how you'd represent those templates would be
> in Python.
> I do not think that the proposal can be properly understood without that.
>
What about the *__getitem__* of Add and Mul? So we could have
Add[AssocOp](x, y, z) ==> x + y + z
w = var('w', commutative=False)
Add[NonCommutative](x, w) ==> x + w
and the multiple dispatch could look like:
@dispatch(Add[NonCommutative], Add[InfinitiesT])
def f(x, y):
# This function is called only when x is an Add with
# non-commutative elements, while x is
# an Add containing infinities.
...
Of course the hard part is not this, it's reorganizing the rules inside
these template-like objects.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.