digitalmars.D - methods and instance variables cannot share a name
- stonecobra (15/15) Jul 29 2004 This is more for historical searching purposes, and to let people know
- Regan Heath (6/20) Jul 29 2004 How does Java treat the above?
- Mike Parker (7/28) Jul 30 2004 Java knows the difference between a method and a member via the
- stonecobra (5/39) Jul 30 2004 Correct, in Java the parens are required. In D, they are optional,
- Regan Heath (16/45) Jul 31 2004 Whereas D allows you to access a member function like the above with or
This is more for historical searching purposes, and to let people know that it is a difference between Java and D. In my translation of Java to D at the source level, I cam across a class in Java that looks like: Class SomeSet { KeySet keySet; KeySet keySet() { ... } } It is my understanding that this is incorrect in D and is as-designed, correct? So, I am merely try to rename one of them and move on, just wanted to let people know. Scott Sanders
Jul 29 2004
On Thu, 29 Jul 2004 19:47:46 -0700, stonecobra <scott stonecobra.com> wrote:This is more for historical searching purposes, and to let people know that it is a difference between Java and D. In my translation of Java to D at the source level, I cam across a class in Java that looks like: Class SomeSet { KeySet keySet; KeySet keySet() { ... } } It is my understanding that this is incorrect in D and is as-designed, correct? So, I am merely try to rename one of them and move on, just wanted to let people know.How does Java treat the above? Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 29 2004
Regan Heath wrote:On Thu, 29 Jul 2004 19:47:46 -0700, stonecobra <scott stonecobra.com> wrote:Java knows the difference between a method and a member via the parentheses. It helps that you can't pass around function pointers in Java. These days, I've noticed more and more code where Java programmers are abandoning the traditional get/set syntax for method names where 'properties' are concerned, and end up naming the member and both methods the same.Class SomeSet { KeySet keySet; KeySet keySet() { ... } } It is my understanding that this is incorrect in D and is as-designed, correct? So, I am merely try to rename one of them and move on, just wanted to let people know.How does Java treat the above?
Jul 30 2004
Mike Parker wrote:Regan Heath wrote:Correct, in Java the parens are required. In D, they are optional, correct, so there is an ambiguous definition. Java has no problem, since they are not ambiguous, ie (keySet != keySet()). ScottOn Thu, 29 Jul 2004 19:47:46 -0700, stonecobra <scott stonecobra.com> wrote:Java knows the difference between a method and a member via the parentheses. It helps that you can't pass around function pointers in Java. These days, I've noticed more and more code where Java programmers are abandoning the traditional get/set syntax for method names where 'properties' are concerned, and end up naming the member and both methods the same.Class SomeSet { KeySet keySet; KeySet keySet() { ... } } It is my understanding that this is incorrect in D and is as-designed, correct? So, I am merely try to rename one of them and move on, just wanted to let people know.How does Java treat the above?
Jul 30 2004
On Fri, 30 Jul 2004 16:11:19 +0900, Mike Parker <aldacron71 yahoo.com> wrote:Regan Heath wrote:Whereas D allows you to access a member function like the above with or without the parens as part of the properties feature of D.On Thu, 29 Jul 2004 19:47:46 -0700, stonecobra <scott stonecobra.com> wrote:Java knows the difference between a method and a member via the parentheses.Class SomeSet { KeySet keySet; KeySet keySet() { ... } } It is my understanding that this is incorrect in D and is as-designed, correct? So, I am merely try to rename one of them and move on, just wanted to let people know.How does Java treat the above?It helps that you can't pass around function pointers in Java. These days, I've noticed more and more code where Java programmers are abandoning the traditional get/set syntax for method names where 'properties' are concerned, and end up naming the member and both methods the same.In the case of D I tend to do the following... class { int fooBar() { return _fooBar; } int fooBar(int value) { _fooBar = value; } private: int _fooBar } so, if you were going to do that, then a rename of the member variable is the correct conversion step to take. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 31 2004