4 ms·
> In CL can you add/remove fields on the class and the existing instances get updated? What happens to new fields how are they initialized in that case? yes, a
by vindarel 4y ago
> In CL can you add/remove fields on the class and the existing instances get updated? What happens to new fields how are they initialized in that case?
yes, and you can even specialize built-in methods so that the update does exactly what you want O_o See update-instance-for-redefined-class. It takes as arguments the added slots, the discarded ones, it's supposed to do the right thing but we can customize it.
- didibus 4y agoAh I see, ya that's a pretty neat feature for an OO language. You wouldn't get that in Clojure for defining types, since they'd be Java types and then they only get what features the Java runtime allows on types and it doesn't have that one. But in practice, since Clojure is functional, it's kind of a non-issue. I should really try CL to be sure, but it seems you'd get 95% or more of the same interactivity in Clojure. What I can tell you is I find Clojure superior to Emacs LISP in interactivity (which I've used both extensively). Emacs can technically redefine more things inside-out, like it can do the full runtime rebuild from the example link, but because it isn't functional and immutable first, managing the state as you redefine things tends to be more complex, and I find that makes it less interactive, since I need to do a lot of state setup and teardown to get things back to what I want to re-evaluate.