www.digitalmars.com         C & C++   DMDScript  

D.gnu - Properties implemented in DLI?

reply Brad Beveridge <brad clear.net.nz> writes:
Hi guys.  I'm playing with D at the moment, it's quite nice.  I'm 
checking out properties, ie..
class Mytest
{
	int tmp;
	
	void tp(int newTmp) { printf("assigning tmp\n"); tmp =newTmp;};
	int tp() { printf("getting tmp\n"); return tmp;};
}

but DLI gives me the following errors
test.d(48): Error: cannot implicitly convert int to void(int newTmp)
test.d(49): Error: cannot implicitly convert void(int newTmp) to int

Is this a problem in my code, lack of implementation in Walter's 
frontend or a missing section in DLI?
If it is a DLI issue could someone point me to a place to look to 
implement it?

Cheers
Brad
Jan 17 2003
next sibling parent reply Ilya Minkov <midiclub 8ung.at> writes:
Does your class really look like that?
haven't you forgotten a little thing?
did you try to compile the piece you're sending?
here the identifiers simply don't match. i've marked them below.

Brad Beveridge wrote:
 Hi guys.  I'm playing with D at the moment, it's quite nice.  I'm 
 checking out properties, ie..
 class Mytest
 {
     int tmp;
^^^tmp!!!
     
     void tp(int newTmp) { printf("assigning tmp\n"); tmp =newTmp;};
     int tp() { printf("getting tmp\n"); return tmp;};
^^ tp!!!
 }
 
 but DLI gives me the following errors
 test.d(48): Error: cannot implicitly convert int to void(int newTmp)
 test.d(49): Error: cannot implicitly convert void(int newTmp) to int
 
 Is this a problem in my code, lack of implementation in Walter's 
 frontend or a missing section in DLI?
 If it is a DLI issue could someone point me to a place to look to 
 implement it?
 
 Cheers
 Brad
 
Jan 17 2003
parent reply Brad Beveridge <brad clear.net.nz> writes:
That's what I originally thought too, but according to the sample code 
in the D spec...

class Abc
	{	int myprop;
		void property(int newproperty) { myprop = newproperty; } // set'er
		int property() { return myprop; }	// get'er
	}

Personally I'd like to keep the property & it's setters/getters similar, 
but still different.  If they're difference then I can more clearly know 
what I am trying to do - ie am I try to access the var directly, or 
though the property methods - I don't want the variable to exactly 
shadow the getters/settors.

I suspect I will take a code style where my internal variables that are 
accessed through setters/getters have some kind of pre or postfix - ie
_property or somesuch.


Cheers
Brad


Ilya Minkov wrote:
 Does your class really look like that?
 haven't you forgotten a little thing?
 did you try to compile the piece you're sending?
 here the identifiers simply don't match. i've marked them below.
 
 Brad Beveridge wrote:
 
 Hi guys.  I'm playing with D at the moment, it's quite nice.  I'm 
 checking out properties, ie..
 class Mytest
 {
     int tmp;
^^^tmp!!!
         void tp(int newTmp) { printf("assigning tmp\n"); tmp =newTmp;};
     int tp() { printf("getting tmp\n"); return tmp;};
^^ tp!!!
 }
 but DLI gives me the following errors
 test.d(48): Error: cannot implicitly convert int to void(int newTmp)
 test.d(49): Error: cannot implicitly convert void(int newTmp) to int

 Is this a problem in my code, lack of implementation in Walter's 
 frontend or a missing section in DLI?
 If it is a DLI issue could someone point me to a place to look to 
 implement it?

 Cheers
 Brad
Jan 17 2003
parent Ilya Minkov <midiclub 8ung.at> writes:
Brad Beveridge wrote:
 That's what I originally thought too, but according to the sample code 
 in the D spec...
 
 class Abc
     {    int myprop;
         void property(int newproperty) { myprop = newproperty; } // set'er
         int property() { return myprop; }    // get'er
     }
Damnit, i was looking at the very same piece of code in the manual, and didn't notice the identifiers here are different too... I guess i need to force myself to sleep more. sorry for misleading.
 
 Personally I'd like to keep the property & it's setters/getters similar, 
 but still different.  If they're difference then I can more clearly know 
 what I am trying to do - ie am I try to access the var directly, or 
 though the property methods - I don't want the variable to exactly 
 shadow the getters/settors.
 
 I suspect I will take a code style where my internal variables that are 
 accessed through setters/getters have some kind of pre or postfix - ie
 _property or somesuch.
 
 
 Cheers
 Brad
 
 
 Ilya Minkov wrote:
 
 Does your class really look like that?
 haven't you forgotten a little thing?
 did you try to compile the piece you're sending?
 here the identifiers simply don't match. i've marked them below.

 Brad Beveridge wrote:

 Hi guys.  I'm playing with D at the moment, it's quite nice.  I'm 
 checking out properties, ie..
 class Mytest
 {
     int tmp;
^^^tmp!!!
         void tp(int newTmp) { printf("assigning tmp\n"); tmp =newTmp;};
     int tp() { printf("getting tmp\n"); return tmp;};
^^ tp!!!
 }
 but DLI gives me the following errors
 test.d(48): Error: cannot implicitly convert int to void(int newTmp)
 test.d(49): Error: cannot implicitly convert void(int newTmp) to int

 Is this a problem in my code, lack of implementation in Walter's 
 frontend or a missing section in DLI?
 If it is a DLI issue could someone point me to a place to look to 
 implement it?

 Cheers
 Brad
Jan 17 2003
prev sibling parent reply Burton Radons <loth users.sourceforge.net> writes:
Brad Beveridge wrote:
 Hi guys.  I'm playing with D at the moment, it's quite nice.  I'm 
 checking out properties, ie..
 class Mytest
 {
     int tmp;
     
     void tp(int newTmp) { printf("assigning tmp\n"); tmp =newTmp;};
     int tp() { printf("getting tmp\n"); return tmp;};
 }
 
 but DLI gives me the following errors
 test.d(48): Error: cannot implicitly convert int to void(int newTmp)
 test.d(49): Error: cannot implicitly convert void(int newTmp) to int
Properties support is in the very latest version (http://www.opend.org/dli/arc/dli-0.1.2.tar.gz). I see that the menu bar on OpenD is still linking to 0.1.1, I'll have to fix that.
Jan 17 2003
parent Brad Beveridge <brad clear.net.nz> writes:
Thanks, grabbing it now..

Burton Radons wrote:
 
 
 Brad Beveridge wrote:
 
 Hi guys.  I'm playing with D at the moment, it's quite nice.  I'm 
 checking out properties, ie..
 class Mytest
 {
     int tmp;
         void tp(int newTmp) { printf("assigning tmp\n"); tmp =newTmp;};
     int tp() { printf("getting tmp\n"); return tmp;};
 }

 but DLI gives me the following errors
 test.d(48): Error: cannot implicitly convert int to void(int newTmp)
 test.d(49): Error: cannot implicitly convert void(int newTmp) to int
Properties support is in the very latest version (http://www.opend.org/dli/arc/dli-0.1.2.tar.gz). I see that the menu bar on OpenD is still linking to 0.1.1, I'll have to fix that.
Jan 17 2003