On Nov 25, 2007 12:13 PM, Nick Alexander <[EMAIL PROTECTED]> wrote: > Hi William, > > I've been thinking about > > http://sagetrac.org/sage_trac/ticket/1135 > > for about 2 days now. I can think of no obvious way to handle the > following three cases: > > R.<x, y> = PolynomialRing(ZZ) # names should be added > R.<x, y> = PolynomialRing(ZZ, 'x, y') # names should not be added > R.<x, y> = PolynomialRing(ZZ, 'a, b') # names should not be added > > smoothly. In general, deciding whether the caller has included names > is equivalent to the halting problem. Due to Python's line-as-block > syntax, preprocessing *cannot add newlines*, making it essentially > impossible to add try/except blocks. (I've tried -- if it works at > the prompt, it fails in doctests.) > > What I think we should do is process "R.<x, y> = PolynomialRing(ZZ)" to > > with __default_var_context('x, y'): R = PolynomialRing(ZZ); (x, y, ) > = R._first_ngens(2); > > And then have normalize_names in parent_gens.pyx check to see if > there is a default var context in place when creating a ring with no > names specified. This would let "R.<x, y> = PolynomialRing(ZZ, 'a, > b')" be handled uniformly. > > The only reason to use with: rather than just assignment is that it > is possible to guarantee default variable names do not remain in > scope too long. > > Thoughts? > Nick > > PS. I'll try a quick implementation soon, but I don't want to waste > time if there is some reason this is a bad idea.
If this works I think it would be an extremely good idea. I can't see a problem with it yet. Though implementing it could suggest problems. It also relates to some people's desire to have a mechanism for having a default variable name, e.g., always use "x" or "x0,x1,x2,..." if nothing is specified. -- William -- 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/ -~----------~----~----~----~------~----~------~--~---