3 ms·
The difference is NSInvocation. A function pointer doesn't capture the arguments to the function, but a message does. Also, you can change the destination of a
by astrange 2y ago
The difference is NSInvocation. A function pointer doesn't capture the arguments to the function, but a message does.
Also, you can change the destination of a message send at runtime, but you can't change the destination of a function call unless you're dtrace and can do code patching.
- em-bee 2y agook, so that means message passing needs a runtime, and it can be assumed that pretty much every language that has a runtime uses message passing. more evidence that it is message passing that won out. and the profound enlightenment ( https://news.ycombinator.com/item?id=42130432 https://news.ycombinator.com/item?id=42130432 ) is not specific to message passing but about a dynamic language runtime. being able to intercept messages/function calls is just one of the benefits of that.
- astrange 2y agoNot sure if objc_msgSend is a runtime, but it does require malloc, so there are limits to how low level it can be.
- mpweiher 2y ago> objc_msgSend [...] does require malloc, Are you sure about that? ]pwd objc4/runtime/Messengers.subproj ]rg malloc ] The two variants I implemented way back when also did not require malloc. And of course NeXT used objc_msgSend() in the kernel, to good effect, so that's pretty low-level.