3 ms·
Ruby gets close (which is one of the reasons I use it a lot): * Function calls are messages sent to objects, which can be sent to any object directly with Obje
by pdkl95 8y ago
Ruby gets close (which is one of the reasons I use it a lot):
* Function calls are messages sent to objects, which can be sent to any object directly with Object#send and received as messages when an object[1] responds to #message_missing.
* Local state is stored in objects as @foo variables. Ruby is a multi-paradigm language, so it's not strict about enforcing the privacy of local state, but that's rarely a big deal. Ruby softly encourages using an OOP message-passing style with e.g. Module.attr_accessor defining simple accessor wrappers instead of reading local state directly.
* The extreme lateness and mutability of binding in Ruby is (in)famous for making ruby slow and hard to optimize.
[1] I don't mean "defined in the class"; changes can be specific to a particular object instance.
obj = Object.new
obj.define_singleton_method(:method_missing) do |method,*args|
puts method.to_s.capitalize
end
obj.hello! # prints "Hello!"