FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Autocomplete a function as a property?

 
Post new topic   Reply to topic     Forum Index -> Descent
View previous topic :: View next topic  
Author Message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Mon Oct 06, 2008 7:32 am    Post subject: Autocomplete a function as a property? Reply with quote

Is there a way to autocomplete a function as a property?
Back to top
View user's profile Send private message
asterite



Joined: 01 Jun 2006
Posts: 235
Location: Buenos Aires, Argentina

PostPosted: Mon Oct 06, 2008 11:21 am    Post subject: Reply with quote

Yes. If you press = instead of enter when autocompleting a setter, you'll get
Code:
var.foo = |value|;


Check "Other tips" in http://www.dsource.org/projects/descent/wiki/Shortcuts

I can't remember well now, but I think that if you press ; when autocompleting a getter, you don't get the extra parenthesis. But I'm not sure.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Oct 07, 2008 4:23 am    Post subject: Reply with quote

It's not working for me, neither = or ;
Back to top
View user's profile Send private message
asterite



Joined: 01 Jun 2006
Posts: 235
Location: Buenos Aires, Argentina

PostPosted: Tue Oct 07, 2008 5:00 am    Post subject: Reply with quote

The ; is not working (I just tried it), but the = is definitely working. I've tried this:

Code:
class Foo {
   
   void property(int someValue) {
      
   }
   
   void prop() {
      
   }
   
}

void lala(Foo foo) {
   foo.pro
}


I autocomplete after foo.pro, select the item "property(int x) void - void Foo" and press = (in my keyboard, I have to do shift+0 (zero)). The result is:

Code:
void lala(Foo foo) {
   foo.property = someValue
}


Can you confirm this is not working for you in the latest nightly build?
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Oct 07, 2008 8:36 am    Post subject: Reply with quote

I find the problem, if I have a return value for the property it's not working. http://www.digitalmars.com/d/1.0/property.html
Code:
struct Foo
{
    int data() { return m_data; }   // read property

    int data(int value) { return m_data = value; } // write property

  private:
    int m_data;
}

This is how the digitalmars site says how to create a property
Back to top
View user's profile Send private message
asterite



Joined: 01 Jun 2006
Posts: 235
Location: Buenos Aires, Argentina

PostPosted: Tue Oct 07, 2008 9:10 am    Post subject: Reply with quote

But... do you select the method (setter) to autocomplete, and then press "="?

For example, in the suggestions you would see:

Quote:
data() int - Foo
data(int value) void - Foo


Now, if you have the first option highlighted and you press "=", you won't get the setter autocompleted. You have to press the down arrow key to select the second option, and there press "=".

If you want to, you can create a feature enhancment that does that: if you press "=" in a getter, you get the setter aucompleted.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Oct 07, 2008 3:00 pm    Post subject: Reply with quote

asterite wrote:
But... do you select the method (setter) to autocomplete, and then press "="?


Yes. When I have a return value for the setter it doesn't work. Try to add a return value to the setter.

descent 0.5.3.20080925
Back to top
View user's profile Send private message
asterite



Joined: 01 Jun 2006
Posts: 235
Location: Buenos Aires, Argentina

PostPosted: Tue Oct 07, 2008 10:52 pm    Post subject: Reply with quote

Ok, I found it. The thing is, I thought setters are:

void name(type argument);

and your setter is:

int data(int value);

I considered a setter to have a void return value.

But you are right, in the documentation it just says "a method with one argument", saying nothing about the return type. In fact, your example is here: http://digitalmars.com/d/1.0/property.html

I'll fix that for the next release. Thanks!!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Wed Oct 08, 2008 4:48 am    Post subject: Reply with quote

asterite wrote:
In fact, your example is here: http://digitalmars.com/d/1.0/property.html
I have always used setters with a return value because of that example and because of it's in the documentation there's a chance that other people will do the same.

asterite wrote:
I'll fix that for the next release. Thanks!!
Thanks
Back to top
View user's profile Send private message
asterite



Joined: 01 Jun 2006
Posts: 235
Location: Buenos Aires, Argentina

PostPosted: Wed Oct 08, 2008 1:21 pm    Post subject: Reply with quote

New nightly build... Wink

http://downloads.dsource.org/projects/descent/
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Thu Oct 09, 2008 5:44 am    Post subject: Reply with quote

This topic is fixed in the latest nightly build but not ticket 129: http://www.dsource.org/projects/descent/ticket/129#comment:2
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Descent All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group