3 ms·
Yes if there were special Ruby source files that only had classes and modules at the top level, and only defined nested classes and modules and methods in those
by chrisseaton 10y ago
Yes if there were special Ruby source files that only had classes and modules at the top level, and only defined nested classes and modules and methods in those, then it would be a lot quicker to load things.
- burke 10y agoYep. But even then though, what if: class A B = "c".freeze end And elsewhere: class String def freeze raise "because I can, that's why" end # or even method_added, TracePoint, ... end It feels like something should be possible here, but it's really steep uphill battle.
- chrisseaton 10y agoRight - that's why I said nothing but methods and nested classes - expressions in method bodies would be disallowed. And tracing and method added hooks and so on, yes. You could say it was a separate language .rb-module or something, to make it formal.
- burke 10y agoOh, huh, yeah, that makes sense. That would totally work. Cool idea.
- dragonwriter 10y ago> Right - that's why I said nothing but methods and nested classes - expressions in method bodies would be disallowed. I presume you mean "expressions that aren't method definitions in class bodies" (though that's a problem, because of things like attribute declarations) rather than "expressions in method bodies", since methods with no expressions in their bodies would be pointless.