[sage-devel] Re: Question about scoping

2012-01-17 Thread Keshav Kini
Leif and I had a discussion about this on #sagemath in October, but never brought it to sage-devel for some reason. Linked here as it may be relevant: http://boxen.math.washington.edu/home/keshav/files/irclog-var.txt Basically, if we are already encouraging the syntax "var('x')" instead of "x =

Re: [sage-devel] Re: Question about scoping

2012-01-17 Thread William Stein
On Jan 17, 2012 10:25 AM, "Jason Grout" wrote: > > On 1/17/12 12:18 PM, Jason Grout wrote: >> >> On 1/17/12 12:11 PM, William Stein wrote: >>> >>> >>> On Jan 17, 2012 10:06 AM, "Jason Grout" >> > wrote: >>> > >>> > On 1/17/12 12:01 PM, William Stein wrote: >>> >

[sage-devel] Re: Question about scoping

2012-01-17 Thread Jason Grout
On 1/17/12 12:18 PM, Jason Grout wrote: On 1/17/12 12:11 PM, William Stein wrote: On Jan 17, 2012 10:06 AM, "Jason Grout" mailto:jason-s...@creativetrax.com>> wrote: > > On 1/17/12 12:01 PM, William Stein wrote: > >> Nils example is interesting though, since it suggests using SR.var >> instead

[sage-devel] Re: Question about scoping

2012-01-17 Thread Jason Grout
On 1/17/12 12:11 PM, William Stein wrote: On Jan 17, 2012 10:06 AM, "Jason Grout" mailto:jason-s...@creativetrax.com>> wrote: > > On 1/17/12 12:01 PM, William Stein wrote: > >> Nils example is interesting though, since it suggests using SR.var >> instead of var in preparsing callable symbol

Re: [sage-devel] Re: Question about scoping

2012-01-17 Thread William Stein
On Jan 17, 2012 10:06 AM, "Jason Grout" wrote: > > On 1/17/12 12:01 PM, William Stein wrote: > >> Nils example is interesting though, since it suggests using SR.var >> instead of var in preparsing callable symbolic function creation. >> E.g., instead of >> >> sage: preparse('f(x) = 10*x') >> '__tm

[sage-devel] Re: Question about scoping

2012-01-17 Thread Nils Bruin
On Jan 17, 9:53 am, Burcin Erocal wrote: > Are we also going to prevent people from defining callable expressions > using the f(x) = x+1 syntax within functions? That would be a corollary given how that gets preparsed. That might have to change because the error message generated by "var" will be

[sage-devel] Re: Question about scoping

2012-01-17 Thread Jason Grout
On 1/17/12 12:01 PM, William Stein wrote: Nils example is interesting though, since it suggests using SR.var instead of var in preparsing callable symbolic function creation. E.g., instead of sage: preparse('f(x) = 10*x') '__tmp__=var("x"); f = symbolic_expression(Integer(10)*x).function(x)' d

Re: [sage-devel] Re: Question about scoping

2012-01-17 Thread William Stein
On Tue, Jan 17, 2012 at 9:53 AM, Burcin Erocal wrote: > On Tue, 17 Jan 2012 09:02:11 -0800 (PST) > Nils Bruin wrote: > >> On Jan 17, 2:54 am, Keshav Kini wrote: >> [...] >> > How does it make anything easier >> > or clearer or better for the interactive user that var() injects >> > things into g

Re: [sage-devel] Re: Question about scoping

2012-01-17 Thread Burcin Erocal
On Tue, 17 Jan 2012 09:02:11 -0800 (PST) Nils Bruin wrote: > On Jan 17, 2:54 am, Keshav Kini wrote: > [...] > > How does it make anything easier > > or clearer or better for the interactive user that var() injects > > things into global scope? We found ourselves trying in vain to > > explain thi

[sage-devel] Re: Question about scoping

2012-01-17 Thread Nils Bruin
On Jan 17, 2:54 am, Keshav Kini wrote: [...] > How does it make anything easier > or clearer or better for the interactive user that var() injects things > into global scope? We found ourselves trying in vain to explain this to > students several times when teaching our Sage-based undergraduate co

Re: [sage-devel] Re: Question about scoping

2012-01-17 Thread Michael Orlitzky
On 01/17/12 09:29, Jason Grout wrote: > > You can do this: > > var('x') > > instead of this: > > x=var('x') > > That's less error-prone (you don't have to type/mistype the variable > twice), easier to type, etc. > (completely off-topic) There should really be a page explaining the different

[sage-devel] Re: Question about scoping

2012-01-17 Thread Keshav Kini
OK, but that only explains why it injects things into a scope. Why does it inject them into the *global* scope, and not the local scope? Or is this not possible? -Keshav Join us in #sagemath on irc.freenode.net ! -- To post to this group, send an email to sage-devel@googlegroups.com To u

[sage-devel] Re: Question about scoping

2012-01-17 Thread Jason Grout
On 1/17/12 4:54 AM, Keshav Kini wrote: On Tuesday, January 17, 2012 6:06:25 PM UTC+8, luisfe wrote: On Jan 16, 5:53 pm, Ed Scheinerman wrote: > I'm confused by the fact that variables defined inside functions can > "leak out" and become global variables. Here's what I've notic

[sage-devel] Re: Question about scoping

2012-01-17 Thread Keshav Kini
On Tuesday, January 17, 2012 6:06:25 PM UTC+8, luisfe wrote: > On Jan 16, 5:53 pm, Ed Scheinerman > wrote: > > I'm confused by the fact that variables defined inside functions can > > "leak out" and become global variables. Here's what I've noticed. > > The problem is twith the function var.