3 ms·
"because files are indeed "compilation units" in Ruby. If I have a running irb session where I've imported code from 20 different Ruby files, and I change the c
by mattmcknight 9y ago
"because files are indeed "compilation units" in Ruby. If I have a running irb session where I've imported code from 20 different Ruby files, and I change the code in one of those files, I can just call load on that file again and it should fix anything up, even if that file is monkeypatching a class that's also defined in seven other files."
I should have been more clear, Ruby is not compiled. It is interpreted. Compilation units are a concept from the Java Langauge Spec. That concept does not clearly map to Ruby.
- philwelch 9y agoThe Ruby interpreter compiles to bytecode, which is then passed to the VM, which isn’t that far off from classical Java. JRuby also seems to support ahead-of-time compilation. In any case, the fact that a single Ruby source file can be incrementally loaded into the runtime despite altering classes and modules defined elsewhere supports, rather than detracts, from the author’s notion of a “compilation unit”. Python, in contrast, tightly couples code files (“compilation units”) with modules.