On Sat, 28 Oct 2006 06:47:59 -0500, David Harvey  
<[EMAIL PROTECTED]> wrote:
> On Oct 28, 2006, at 3:18 AM, William Stein wrote:
>> Moreover, if you use R['...'] notation anywhere in library code it
>> doesn't
>> affect the interpreter's variables at all -- it only affects the
>> scope where
>> R['...'] is used.
>
> I'm not sure if I totally believe this.

It is true.  I've done tests.  However, it's not true in Pyrex code, which
is why it's possible to do this -- but for Python library code
the module scope is different and what I said above is true.

> Does it work correctly if someone types this from the ipython prompt:
>
> sage: S = ZZ['x']
> sage: def f():
> ...            T = QQ['x']
> sage: f()
> sage: parent(x)
> ???
>
> i.e. is "x" being defined in the scope of f, or in global scope?
>
> i.e. does it have the same behaviour as
>
> sage: S.<x> = PolynomialRing(ZZ)
> sage: def f():
> ...            T.<x> = PolynomialRing(QQ)
> sage: f()
> sage: parent(x)
> Univariate Polynomial Ring in x over Integer Ring

The behavior there is not the same.   I.e., after calling f x will
be set to the QQ variable.  But that's *not* library code.

Obviously there are some potential drawbacks to this. But from
a usability point of view the good outweighs the bad.  I spent
a week just now at an algebraic geometry software conference,
and was very surprised to learn that the MAGMA (=SAGE) way of
defining polynomial indeterminates is not what any other algebraic
geometry software does, and during the MAGMA tutorial I even got
the impression that it is very broken from an interactive usability
point of view.  All other systems do something like
    QQ[x,y,z,w]
and then the variables are defined.

One nice thing about doing this is that we could get rid of the
    T.<x> = blah
preparser notation.  I'm always very happy when the preparser
gets simpler!   I got rid of a ton of code related to list indexes
with Python 2.5's new __index__ method.

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to