Just an idea, every REPL interaction sexp is wrapped in #%top-interaction, that could be how it communicates to set!, but I don't really know.
Jay On Wed, Aug 25, 2010 at 5:52 PM, Danny Yoo <[email protected]> wrote: > I wanted to make sure I understand how toplevel variables, REPLs and > namespaces work. I need to understand this because what I'm doing in > WeScheme's REPL is not quite right because it doesn't match what is > happening with DrRacket's REPL. > > I see that the error messages regarding toplevel variables are > slightly different, depending on context. e.g. set! can produce > either the error message > > set!: unbound identifier in module in: x > > or the message: > > set!: cannot set undefined variable: x > > depending on the compilation context. Furthermore, from talking with > Carl Eastlund, I understand that interactions do something with > namespaces when hitting toplevel variables. The following transcript > confirms to me that toplevel variable lookup and set! cooperates with > namespaces, at least at the REPL: > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >> my-unbound-variable > reference to undefined identifier: my-unbound-variable > >> (set! x 16) > set!: cannot set undefined variable: x > >> (namespace-set-variable-value! 'my-unbound-variable "hello world") > >> my-unbound-variable > "hello world" > >> (set! my-unbound-variable 'ok) > >> my-unbound-variable > 'ok > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > I'm trying to understand what's happening. How does set! know in what > context (definitions or interactions) it is being used? What in the > documentation should I be looking at to better understand this? > _________________________________________________ > For list-related administrative tasks: > http://lists.racket-lang.org/listinfo/users > -- Jay McCarthy <[email protected]> Assistant Professor / Brigham Young University http://teammccarthy.org/jay "The glory of God is Intelligence" - D&C 93 _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

