You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not a good or a bad idea, it's a design choice. I prefer the current state for the following reason: encapsulation is stronger and if you want to expose a field, you have to opt in and write a getter. Making all fields public by default would be exactly the contrary, you would have to propose something to opt out (naming rule, keyword or something else).
At one point, I thought about introducing something like attr_reader/attr_writer/attr_accessor from Ruby. But in the end, writing x { @x } is shorter and more explicit than attr_reader x.
agate/examples/logo.agate
Lines 166 to 168 in 9a2f4fc
Making instance fields have these style of getters by default would eliminate these kinds of lines.
To allow the getters to not automatically be added you could define some sort of naming rule for "private" fields -- Python uses
__name
.does this sound like a good idea?
The text was updated successfully, but these errors were encountered: