Dot Notation Confusion


#1

At the top of page 105 I’m not getting this line of code:

How can a value be assigned to the result of calling the getter?


#2

That’s the exact issue that we take with dot notation.

When you say
x.fido = 3;
you’re not invoking a getter. You’re invoking a setter.

That means that whether the setter or getter is invoked by the dot depends on the context in which its used. This can really throw off folks that are new to the language.

Whether you end up using dot notation later on is totally your call, but we recommend using setters and getters explicitly until you’re very comfortable with the language.


#3

Like Mikey said, dot notation can call either a setter or getter, and it produces what to me can be confusing syntax when you start getting nested calls with both. I like the bracketing and the fact it’s obvious when messages are being sent and what those messages do - either set or get. And the language is after all built on Smalltalk and messaging - the dot notation was a later addition and seems like it was thrown in to imitate Java and such.


#4

Thank you both. I’m going to stick with explicit setters and getters.