Is defining get/set methods for every field overkill?
Sat Nov 19 03:39:18 UTC 2022
On Saturday, 19 November 2022 at 03:22:12 UTC, thebluepandabear
wrote:
> On Saturday, 19 November 2022 at 03:19:53 UTC, []() {}() wrote:
>> On Thursday, 17 November 2022 at 09:52:11 UTC, Dukc wrote:
>>> ..
>>> D has far less need for getters/setters than Java or C++. The
>>> reason is [Uniform Function Call
>>> Syntax](https://ddili.org/ders/d.en/ufcs.html). This means
>>> that a member of a `struct` or `class` can start out as a
>>> normal field and be later converted to getter/setter if
>>> needed, without breaking calling code.
>>> ..
>>
>> can you give an example please.
>>
>> i.e. before (class with public member) and after ( i.e. that
>> public member converted to getter/setter).
>
> Did you read the link provided? There's examples there...
it's say for member functions, not member variables.
I read it, but I dont get the point was being made about how use
ufcs to convert a public member variable of a class type into a
getter and setter. Was there an example in the link that I missed?
More information about the Digitalmars-d-learn
mailing list