4 ms·
Yep. But even then though, what if: class A B = "c".freeze end And elsewhere: class String def freeze raise "because I can, t
by burke 9y ago
Yep. 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 9y 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 9y agoOh, huh, yeah, that makes sense. That would totally work. Cool idea.
- dragonwriter 9y 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.