My proposition regarding properties (already suggested) is much simpler. Why not just treat properties as a pure shortcut for simple getters and setters? This is something I implemented myself in my compiler, and I quite like it.
Advantages :
- it's crystal clear what you're doing, while using setters and getters obfuscate the code.
- absolutely no unneeded syntax change
Really, that can be added in a blink. I know, I did it.
If you find the first version more readable then you've managed to surprise me.
As a second more general point, properties are a way to abstratc away data access. You don't care if some value of an object is computed, stored in a field or even fetched from a database, that's really none of your business (as a client).
Type MyType Method GetColor%() ... End Method Method SetColor(col%) ... End Method End Type Local obj:MyType = New MyType obj.color = obj.color / 2 ' or of course, "obj.color :/ 2" ' Identical to ' obj.SetColor(obj.GetColor() / 2)
Advantages :
- it's crystal clear what you're doing, while using setters and getters obfuscate the code.
- absolutely no unneeded syntax change
Really, that can be added in a blink. I know, I did it.
I still fail to see the purpose of properties
Maybe you just need to use them. As a simple pragmatic point, do you really prefer "obj.SetColor(obj.GetColor() / 2)" over "obj.color :/ 2" ?If you find the first version more readable then you've managed to surprise me.
As a second more general point, properties are a way to abstratc away data access. You don't care if some value of an object is computed, stored in a field or even fetched from a database, that's really none of your business (as a client).