4 ms·
You're the Truffle Ruby person, yeah? Hi! Re: method_missing, I supoose it's not as easy to understand as I thought, which is to say if I understood it better
by PopeDotNinja 8y ago
You're the Truffle Ruby person, yeah? Hi!
Re: method_missing, I supoose it's not as easy to understand as I thought, which is to say if I understood it better, I could explain it better. The best I can do is this...
1. A typical method call in Java means "I pass a message (args) to a method on some object, and block until I get a response", which usually means building of up stack of blocking calls waiting for a response". The message passing is sending the message, which in Java is tightly coupled to receiving the response.
2. In Erlang, you might have a process (think of it as an object for this example [1]), that sends a message to another process. The sending process doesn't need to wait for a response. Erlang does have function calls that feel pretty much exactly like method calls in Java, and then there is message passing between processes, and that separation makes the differences more clear to me, which is not to say I understand things correctly.
3. method_missing in Ruby is kind of like sending a letter in the mail to Santa Clause. There is no physical address for Santa (aka an undefinded function), but someone at the post office looks at the intended destination (SantaClause.mailing_address) of the North Pole and message itself ("I have been good, and want a Nitendo Swith for Xmas"), and determines how to respond (method_missing) to the message.
I do not know if this explanation is any good, so please be kind :) Doing my best!
[1] this article might explain things better than I can... https://blog.noredink.com/post/142689001488/the-most-object-oriented-language https://blog.noredink.com/post/142689001488/the-most-object-...