From: Ken A. <kan...@bb...> - 2004-07-09 17:45:19
|
At 12:22 PM 7/9/2004 -0400, Geoffrey Knauth wrote: >On Jul 9, 2004, at 10:36, Ken Anderson wrote: >>Q1`: >>In src/jsint/Evaluator.java: >>public DynamicEnvironment INTERACTION_ENVIRONMENT >> >>Should this be static final, or should it be named interactionEnvironment? > >Would anyone ever override/replace the interaction environment? >If yes, I vote the latter. If no, I vote the former. Yes, i think it should be an instance field. >>Q2: analyze() >>line 265: >> return new DynamicVariable((Symbol)x, dynamicEnv); >>This returns a new DynamicVariable for each use of a symbol in the body. >>Shouldn't it reuse one if there is one already like Symbol.intern()? >>Though that might require a synchronized method. > >By DynamicVariable I assume you mean a variable of local scope. If that is true, then I think you'd want a new one for each new binding, as opposed to each use. The word "dynamic" is a bit confusing to me, because it means one thing in the context of C or Java, another thing in Common Lisp. And here we are talking about a Scheme written in Java. > >Symbol.intern() -- wouldn't that let you have only one "x", instead of one at the top-level (global scope) and each lower local scope? Or, in the case of (define x 1) (let ((x 2)) ...), are the two x's guaranteed to have different Symbols, interned separately? Yes, the name isn't very informative. Originally, a Symbol had a name and a value field. The value was used to store the global value of the Symbol if any. Several people have contributed code so things are a bit different. A DynamicVariable has a symbol and a DynamicEnvironment which is a hash from symbol -> value. This is what lets the module system work. So if you type x to the REPL The reader returns a the symbol 'x, which the evaluator analyzes and turns into a Dynamic Variable in the evaluator's DynamicEnvironment. It then executes that DV to produce a value, by looking it up in the DV's DE. The DV also has a field that is used to store the value during serialization. This explanation has helped me understand this, and i found a slight bug in serialization and i have a new proposal for DV and DE which i'll send in my next message. k |