Fork me on GitHub
AJ Jaro14:02:19

Has anyone experienced problems with reloading records/protocols in the REPL? I periodically have issues with that where it won’t recognize that my var is referencing a record that implements said protocol.


@ajarosinski are you re-defing the var as well, or just the record?

AJ Jaro14:02:35

I think I’m re-defing the var. For example, I’ll fetch data from the DB in the REPL, convert that to a record and then try to reference the protocol functions on that record. This will fail sometimes if I’ve reloaded either the protocol/record in the incorrect order in the REPL


I think that's expected behavior for records. A record defines an accompanying class, and reloading it generates a new class, so instances that existed before the reload now point to the old class.


tools.namespace docs offers suggestions for structuring your codebase to be more repl friendly:


Stuart Sierra blog posts about his workflow are also useful:


He automated some of it in this project


I generally avoid using records/protocols exactly because they're not very REPL friendly

AJ Jaro17:02:23

Thanks @U5FEGMC4D, I’ll read through those. @U236LQYB0, that’s a bummer that you avoid them for the REPL; I have really enjoyed them otherwise