Le mardi 10 mai 2011 à 11:37 -0700, Luke a écrit :
> The dot and cross products are implemented at the lowest level in
> UnitVector, and the Vector class simply calls these methods on all of
> the UnitVector objects that comprise it when these methods are called
> on a Vector class.
> 
> dot and cross functions are provided as convenience wrapper functions
> around the class methods, so the user can choose to use whichever
> approach is more natural to them.

Not making a choice between the two options might seem easiest in the
short term but it's actually the worst decision in the long term. And
this is Alex Martelli's opinion[1], not mine, so it must be true!

The function interface suggests that the operation is something that
depends equally on the two operands. The method interface suggests that
it's something that the first operand does to the second, or that it's a
characteristic of the first operand influenced by the second. I think
the first interpretation makes more sense. In any case, the current
implementation shouldn't dictate what the interface looks like, because
implementations can always be changed, but modifying an interface is
much more painful.

[1]: See his Pycon 2011 talk
[http://python.mirocommunity.org/video/4230/pycon-2011-api-design-anti-pat] 
from 26:38 and, more specifically, from 29:08. Slides for the talk: 
[http://www.aleax.it/pycon11_adap.pdf]

> ~Luke
> 
> On Tue, May 10, 2011 at 11:02 AM, Vinzent Steinberg
> <vinzent.steinb...@googlemail.com> wrote:
> > On 10 Mai, 03:30, Ronan Lamy <ronan.l...@gmail.com> wrote:
> >> Please, try to make the interface dot(v1, v2), and not v1.dot(v2).
> >
> > While I agree that it looks cleaner for the simple case, I would
> > prefer
> >
> >    v1.dot(v2).dot(v3)
> >
> > over
> >
> >    dot(dot(v1, v2), v3)
> >
> > For the dot product it does of course not make sense to multiply three
> > vectors in a row, but I think we should keep this in mind in general
> > for user defined operations.
> >
> > Vinzent
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sympy" group.
> > To post to this group, send email to sympy@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > sympy+unsubscr...@googlegroups.com.
> > For more options, visit this group at 
> > http://groups.google.com/group/sympy?hl=en.
> >
> >
> 
> 
> 
> -- 
> "Those who would give up essential liberty to purchase a little
> temporary safety deserve neither liberty nor safety."
> 
> -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
> 


-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to