Hi,

I am sorry I haven't reply yet, I had a draft in my mailbox, but I
haven't finish it.

On Mon, Jun 2, 2008 at 12:43 PM, Fredrik Johansson
<[EMAIL PROTECTED]> wrote:
>
> On Mon, Jun 2, 2008 at 11:48 AM, Ondrej Certik <[EMAIL PROTECTED]> wrote:
>> What do you think Fredrik? Let's use explicit in mpmath as well, at
>> least in SymPy?
>
> When a function name changes, you have to change not just the function
> and the code that refers to it, but also lots of imports. You can
> catch errors this way, but those imports should be checked via unit
> tests anyway. In many ways I think explicit imports are a bit like
> (explicit) static type declarations, which I don't like :-)


In the draft I had: But there are not tests of mpmath in sympy.
This is no longer true, I put the mpmath tests in now.

>
> As I've said, it adds a lot of clutter when there are 50 items to
> import. A possible solution is to keep the namespace of the entire
> module (requiring just one import), but that results in even more
> clutter if the imported objects are used in 100 places in the code.
>
> Note that some mpmath modules define __all__, which I think is a good
> compromise, as it prevents "leakage" via subsequent imports. So it
> doesn't really matter to SymPy what mpmath does to import items
> between modules internally.

As long as it doesn't break. But it does break some times:

http://code.google.com/p/sympy/issues/detail?id=864

and it really confuses people as you can see above. It confused me and
Vinzent. So you may say that we are stupid not to realize where the
problem is immediatelly (and you may be right:), or that we didn't
execute tests, which we didn't because there were not tests in sympy
for mpmath back then. But I suspect there are a lot more people who
would get confused.

>
> The argument that things get clearer is valid. But it might be even
> better with a comment such as
>
> # Here we import all the low level functions fadd, fmul, etc, which in
> this module will be wrapped to operate on mpf instances
> from lib import *

Ok, if this is the only place, it might get acceptable as an
exception, but again, if this is the only place, it won't be a problem
to put explicit import to this one place either. BTW, you don't seem
to have the comment you suggested in mpmath. :)
The thing is that if you don't use explicit imports, you need other
mechanisms to ensure QA. Either comments (but you don't write them
anyway), or tests (but mpmath's tests weren't in sympy before either).

My argument is that if something can be made more robust with a one
line change, we should do it, rather than to rely on comments/tests
that weren't there anyway in the issue 864.

I also just asked on sage-devel to get more opinions on this:

http://groups.google.com/group/sage-devel/browse_thread/thread/daeddeed91caaa8b

On Mon, Jun 2, 2008 at 4:11 PM, Vinzent Steinberg
<[EMAIL PROTECTED]> wrote:
>
> When necessary, it's still possible to use 'import stuff as
> shortcut' (well, it's actually not a shortcut in this cas :-), instead
> of 100 explicit imports.

Exactly.

Ondrej

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