Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clojure REPL doesn't pick up changes made to defrecord

I have a leiningen project set up. In one of the clojure source files I've defined some records. My workflow is to usually start emacs and connect to a 'lein swank' REPL. Once I've connected to the REPL I switch into the appropriate namespace and C-c C-k a file, so I can start working with the REPL and the code in the file. However, if I make changes to the records in that file and C-c C-k it, the REPL doesn't pick up the changes.

So, as it stands, every time I need to make changes to a record, I have to stop the lein swank process, restart it, and reconnect to it from emacs. This is getting old very fast. What am I missing? I've tried C-c C-l instead of C-c C-k, but that doesn't work. I've tried deleting the 'class' dir in the project root, but that's also a no-go.

I'd appreciate any insights or recommendations.

Also, as an aside, I'm always working in the namespace where the records are defined.

Edit: I'm actually changing the implementation of a protocol in the defrecord. Once I change it and compile using C-c C-k, and create a new record in the REPL, the REPL is still using the old protocol implementation.

like image 729
mofeeta Avatar asked Oct 11 '22 11:10

mofeeta


1 Answers

I could use an example, but perhaps you are changing the deffinition of the records and looking at instances of some records that where made before the change?

if you define an instance of the record from the repl, then change the defrecord, reload the repl, and then make a new one with a different name can you see both copies and the differences between them.

I try to avoid this kind of confusion by having a file in my project that calls (use :reload-all ... all the namespaces in my project ...) then i can reload just this file and the reload-all throws out the old var bindings etc.

like image 106
Arthur Ulfeldt Avatar answered Oct 21 '22 02:10

Arthur Ulfeldt