On Mar 30, 4:50 am, Brian Granger <[email protected]> wrote:
[...]
> What do people think?
>
> Cheers,
>
> Brian

The advantage of methods is that you can use them in sympy's case as
some kind of user-defined operators. Consider the following example:

(1) x + y + z

This could also be written using methods (please note how '.add' is
syntactically nearly identical to '+' minus precedence):

(2) x.add(y).add(z)

or using functions:

(3) add(x, add(y, z))

The same approach if you allow more arguments:

add(x, y, z)

So there are 3 possible syntaxes for doing the same thing. The
question is, when should/could we prefer which one?

(1) is not always possible, because Python does not allow to define
custom operators. There is however the question if we should overload
operators or rather use (2) or (3) (see for example Assume()).


Should (2) only be used when instances of Expr() (see Ronan's branch,
which should be imho merged before fixing these issues here) are
returned? This would not allow expr.ask() nor expr.evalf().

I think we should do it like Ondrej suggested: implement (2) and (3)
for any sympy function accepting instances of Expr() as argument. And
implement (3) "additionally" if it makes sense.
This would mean that we also need to implement expr.ask().

The basic operations on expressions in sympy are a special case, I
don't think we need (1) for Add(), Mul() or the non-existent Div().


Vinzent

-- 
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