11 ms·
"Essentially, since functions (not objects) are the top-level constructs in Clojure, you can redefine functions at any time while your program is running, and e
by habitue 14y ago
"Essentially, since functions (not objects) are the top-level constructs in Clojure, you can redefine functions at any time while your program is running, and everything will "magically" start using the new definition. "
This isn't exactly correct. It's not because clojure has first class functions that you get this behavior, but because clojure has late binding: http://en.wikipedia.org/wiki/Late_binding http://en.wikipedia.org/wiki/Late_binding
- jballanc 14y agoTrue, but Ruby also has late binding. Ruby also has open classes, so you could (in theory) do something very close to SLIME with Ruby. The problem is, Ruby also has singleton classes and singleton methods, so there's no guarantee that a change made in code and evaluated in the runtime will have the desired effect. Actually, Clojure has a similar problem with defonce, but in practice I've found that Clojure works much better with the SLIME development model than Ruby does.
- banister 14y agoJust curious but why does singleton classes/singleton methods in Ruby make it "so there's no guarantee that a change made in code and evaluated in the runtime will have the desired effect" ?
- jballanc 14y agoWell, a trivial example: class Foo def bar puts "Hello from Foo" end end a = Foo.new def a.bar puts "Hello from a special Foo" end Now, even if you change the definition of "bar" in Foo's class definition, "a" will still have it's own version. This might not seem like a big deal, but as you do more metaprogramming with Ruby, more examples like this pop up.