document this:

Date: Wed, 2 May 2007 15:57:59 -0500
From: "Daniel R. Grayson" <dan@math.uiuc.edu>
To: Thomas Koeppe <t.koeppe@ed.ac.uk>
CC: dan@math.uiuc.edu, mike@math.cornell.edu
In-reply-to: <289D2EAD-1F10-4FC3-BF4D-347C5160CB36@math.cornell.edu> (message
	from Michael Stillman on Tue, 24 Apr 2007 23:44:06 -0400)
Subject: Re: Fwd: Macaulay2: Rings leaking into the global scope
Reply-to: dan@math.uiuc.edu


Dear Thomas,

When you use a global variable such as x or y as the name of a variable in
a ring, the making of the ring may involve setting that variable so its value
is the corresponding indeterminate in the polynomial ring.  That's by design,
so the user doesn't have to explicitly set them.

Here is a way to work around it: make the monoid first, and then the monoid
ring:

    i1 : QQ ( monoid [x,y] )

    o1 = QQ [x, y]

    o1 : PolynomialRing

    i2 : x

    o2 = x

    o2 : Symbol

Here is another way: use local variables x and y instead of global ones:

    i4 : ( () -> QQ[local x, local y] ) ()

    o4 = QQ [x, y]

    o4 : PolynomialRing

    i5 : x

    o5 = x

    o5 : Symbol

Let me know if you have further problems with that, or suggestions about how it
might be better.

> From: Michael Stillman <mike@math.cornell.edu>
> Subject: Fwd: Macaulay2: Rings leaking into the global scope
> Date: Tue, 24 Apr 2007 23:44:06 -0400
> To: Dan Grayson <dan@math.uiuc.edu>
> 
> Here is a comment about rings and global variables...
> 
> Begin forwarded message:
> 
> > From: Thomas Koeppe <t.koeppe@ed.ac.uk>
> > Date: April 24, 2007 8:30:41 PM EDT
> > To: Michael Stillman <mike@math.cornell.edu>
> > Subject: Macaulay2: Rings leaking into the global scope
> >
> > Dear Mike,
> >
> > I wrote to you a while ago about my work with Elizabeth Gasparim  
> > using Macaulay2. The Laurent polynomials are working wonderfully by  
> > now ;-)
> >
> > Now, I've got a different question:
> >
> > When I have a function that _in its local scope_ defines a  
> > polynomial ring, then after calling that function, that ring leaks  
> > into the global scope.
> >
> > Example:
> >
> >> x
> >   Symbol
> >
> >> f = n -> ( QQ[x,y]; return n; );
> >
> >> f(1)
> >   1
> >
> >> x
> >   in QQ[x,y]
> >
> >
> > Is that behaviour by design? I'm finding that when using auxiliary  
> > rings in functions that make and return complicated rings (as  
> > quotients, say), then I don't want any global symbols to be  
> > interpreted
> > as elements of some auxiliary ring that has long gone out of scope...
> >
> >
> > Thanks!
> >
> > Thomas
> >
> >
> > PS: There may be a new paper out soon, I'll let you know. The  
> > programs are on my website, http://www.maths.ed.ac.uk/~s0571100/ 
> > Instanton/ .
> 
> 

