4 ms·
I think there is a simple way around the complexity: Make the field "foo.bar" indistinguishable from the outside from the getter / setter pair bar() / set_bar()
by dukoid 6y ago
I think there is a simple way around the complexity: Make the field "foo.bar" indistinguishable from the outside from the getter / setter pair bar() / set_bar(). This has the disadvantage of losing the ability to distinguish method calls and references by the presence of parens, but I think overall it should pay off.
I have written up some more details here: https://stefan-haustein.com/simplifying-properties https://stefan-haustein.com/simplifying-properties
- duckerude 6y agoThis is also known as the uniform access principle: https://en.wikipedia.org/wiki/Uniform_access_principle https://en.wikipedia.org/wiki/Uniform_access_principle I believe Ruby and Smalltalk more or less work that way.
- deleted 6y ago[deleted]
- dukoid 6y agoThanks a lot for the pointer! I was initially distracted by listing C#, JS and Python as examples, but the article clearly states: "Many programming languages do not strictly support the UAP but do support forms of it. Properties, which are provided in a number of programming languages, address the problem Meyer was addressing with his UAP in a different way. Instead of providing a single uniform notation, properties provide a way to invoke a method of an object while using the same notation as is used for attribute access. The separate method invocation syntax is still available."
- pjmlp 6y agoEiffel was one of the first languages to introduce it that way.