Re: REPL, global, and local scoping

2019-03-21 Thread adam . preble
On Tuesday, March 19, 2019 at 9:49:48 PM UTC-5, Chris Angelico wrote: > I would recommend parsing in two broad steps, as CPython does: > > 1) Take the source code and turn it into an abstract syntax tree > (AST). This conceptualizes the behaviour of the code more-or-less the > way the programmer w

Re: REPL, global, and local scoping

2019-03-19 Thread Chris Angelico
On Wed, Mar 20, 2019 at 1:31 PM wrote: > > On Tuesday, March 19, 2019 at 3:48:27 PM UTC-5, Chris Angelico wrote: > > > I can see in vartest() that it's using a LOAD_GLOBAL for that, yet > > > first() and second() don't go searching upstairs for a meow variable. > > > What is the basis behind thi

Re: REPL, global, and local scoping

2019-03-19 Thread adam . preble
On Tuesday, March 19, 2019 at 3:48:27 PM UTC-5, Chris Angelico wrote: > > I can see in vartest() that it's using a LOAD_GLOBAL for that, yet first() > > and second() don't go searching upstairs for a meow variable. What is the > > basis behind this? > > > > Both first() and second() assign to th

Re: REPL, global, and local scoping

2019-03-19 Thread Chris Angelico
On Wed, Mar 20, 2019 at 7:23 AM wrote: > > I got hit on the head and decided to try to write something of a Python > interpreter for embedding. I'm starting to get into the ugly stuff like > scoping. This has been a good way to learn the real deep details of the > language. Here's a situation:

REPL, global, and local scoping

2019-03-19 Thread adam . preble
I got hit on the head and decided to try to write something of a Python interpreter for embedding. I'm starting to get into the ugly stuff like scoping. This has been a good way to learn the real deep details of the language. Here's a situation: >>> meow = 10 >>> def vartest(): ... x = 1 ..