(no title)
jonhohle | 12 days ago
For the GP, in most languages the dot or arrow operator is field access. If that field is a function reference, parenthesis are used to invoke it.
From outside of the object, neither Ruby or Objective-C allow direct access to object fields or functions. The dot operator sends the object a message that be bound to anything, and even rebound at runtime for specific instances. There is no difference between access and property and calling a function - it’s all messages. Smalltalk and Objective-C (before dot operators) don’t even have different syntax for data fields and functions calls. Ruby’s no arg messages are similar.
Most of the time that distinction doesn’t matter. But writing things like wrappers and proxies becomes trivial. A object can forward any message it receives, and if it sees on it wants to intercept, it can do that easily. Most of the time modifying existing programs and frameworks can be as easy as rebinding some logic to something that wasn’t part of the original program.
This comes at the cost of some runtime performance, and possibly some complexity. The elegance outweighs those, imho.
krackers|10 days ago
Modern obj-c "dot notation" + properties + synthesized ivars add a lot of syntactic sugar that make things more confusing, if you go back to original obj-c where it was just ivars and explicit getters/setters, things are a lot easier to understand.