Michiel Helvensteijn wrote:
Andrei Alexandrescu wrote:Then in a later message you mention: bool empty.get() { ... } void empty.set(bool b) { ... } which I like and which does not seem to have difficulties; the names "get" and "set" will be never used as such.Yes, those are two notations for the same thing, and they have the same problem. Let me demonstrate: -------------------------------------------------- struct S { int get() { return 42; } }; struct T { S _s; S property.get() { return _s; } void property.set(S s) { _s = s; } } T t; auto X = t.property.get(); -------------------------------------------------- What is the type of X? It can be either S or int, depending on how D handles the situation. The ambiguity is in the possibility to directly reference the getter and setter methods. In that other subthread (the older one) I listed some possible solutions. The first is to make such a program an error. The second is not to allow a direct reference to a getter/setter (so X is an int). The third is to let the getter/setter overshadow S members (so X is an S).
I see. My view is that .get and .set are simply symbolic placeholders, but indeed some may get confused.
Andrei
