jasongilman / proto-repl

A Clojure Development Environment package for the Atom editor
https://atom.io/packages/proto-repl
MIT License
563 stars 50 forks source link

Changed code does not (always) take effect when file is reloaded #223

Closed ercancem closed 7 years ago

ercancem commented 7 years ago

The title is a bit cryptic.

Example: I define a function and a simple line to test it, for example:

(defn my-iterate [fn val]
  (cons val (lazy-seq (my-iterate fn (fn val)))))

(take 9 (my-iterate inc 5))

I start the proto-repl console from open project, load my file. Both execute code block from the file and invoking it from the console with some arguments work fine. Then I deliberately break the function. For example:

(defn my-iterate [fn val]
  (cons val (lazy-seq (my-iterateee fn (fn val)))))

(take 9 (my-iterate inc 5))

I save the file, reload the file. If I execute the function definition code block, I get an error as expected. But (take 9 (my-iterate inc 5)) still works. I have to stop and reload the repl.

Am I doing something wrong? What is the correct procedure after editing the current file?

moxaj commented 7 years ago

When you first evaluate the function definition, the function is bound to the var my-iterate. When you evaluate the broken definition, it fails, and nothing changes, the same function is still bound to my-iterate, so (take 9 (my-iterate inc 5)) still works. All of this is expected, I don't really see the issue?

jasongilman commented 7 years ago

I accidentally closed this.

jasongilman commented 7 years ago

Even though I accidentally closed it a minute ago and then reopened it I think that it's not an issue. The comment from the previous user is correct. When you try to define a var in Clojure if the code doesn't compile the var won't be defined/redefined.