April 02, 2008
"Ary Borenszweig" <ary@esperanto.org.ar> wrote in message news:fsti15$a9s$1@digitalmars.com...
> Lionello Lunesu wrote:
>> The whole point of property is that you can simply leave it as a function and the compiler will inline it if it turns out to be a trivial get/set. You're reasoning here is the wrong way around.
>
> To me, the idea of a property is: you use it as it were a field of a struct/class, but it's actually implemented by a function. You want to hide the implementation details from the user. You don't want them to know "Foo.property" is actually a function.

That's what I meant: why would you ever want to change a property 'function' into a data member? You'll end up with less flexibility, and gain nothing.

> Take a look a this, from DFL:
>
> ---
> class Form {
>
>   /// Sets the title of this form
>   void title(string text) {
>     // ...
>   }
>
> }
>
> class Application {
>
>  /// Runs an application whose main form is the given
>  static void run(Form form) {
>    //
>  }
>
> }
> ---
>
> Now you wan to code:
>
> ---
> Form form = new Form();
> form.title // <-- you wan't the IDE to suggest you a property, so
>            // you will end up having "form.title = text"
>
> Application.run // <-- you wan't the IDE to suggest you a function,
>                 // like "Application.run(form)"
>                 // "Application.run = form" looks ugly, and no one
>                 // would recommend you to write that
> ---
>
> How do you configure this? On a per-property basis?

It appears that in both cases the user has knowledge whether the member should be assigned or invoked. The IDE will simply suggest "title" or "run" and pressing "=" or "(" key will finish the job, yielding either "title=" or "run(".

Unless you mean the IDE should have suggested the "=" and "(" as well, but I have never seen an auto-complete that suggests more than just the name. And it sounds like it shouldn't suggest more than that; what if I want a ptr to member function?

My suggestion for a user setting applies to getters. There, when the IDE shows a suggested function/getter, pressing ";" will finish the line and optionally add a pair of ().

L. 

April 02, 2008
Lionello Lunesu wrote:
> It appears that in both cases the user has knowledge whether the member should be assigned or invoked. The IDE will simply suggest "title" or "run" and pressing "=" or "(" key will finish the job, yielding either "title=" or "run(".
> 
> Unless you mean the IDE should have suggested the "=" and "(" as well, but I have never seen an auto-complete that suggests more than just the name. And it sounds like it shouldn't suggest more than that; what if I want a ptr to member function?

Actually, Descent does this, and I find it amusing sometimes.
April 02, 2008
Ary Borenszweig wrote:
> [snip]
> 
> What do you think?

Whatever property syntax is chosen, I believe it should enable properties to work as first-class values. So if you have a class instance frail with property loops, you should be able to do frail.loops++, &frail.loops, and all the other wonderful things impossible with properties currently.

This has already been discussed a number of times before, and Walter has agreed a change might be necessary (see this post: http://tinyurl.com/2s4x6q ), but it's not a priority right now.
April 02, 2008
Lionello Lunesu escribió:
> 
> "Ary Borenszweig" <ary@esperanto.org.ar> wrote in message news:fsti15$a9s$1@digitalmars.com...
>> Lionello Lunesu wrote:
> It appears that in both cases the user has knowledge whether the member should be assigned or invoked. The IDE will simply suggest "title" or "run" and pressing "=" or "(" key will finish the job, yielding either "title=" or "run(".
> 
> Unless you mean the IDE should have suggested the "=" and "(" as well, but I have never seen an auto-complete that suggests more than just the name. And it sounds like it shouldn't suggest more than that; what if I want a ptr to member function?
> 
> My suggestion for a user setting applies to getters. There, when the IDE shows a suggested function/getter, pressing ";" will finish the line and optionally add a pair of ().
> 
> L.

Those are great suggestions!

Eclipse for Java (JDT) suggests you more than the function of the name: it writes, for example:

String s = ...;
s.substring // <-- autocomplete!

and you get

s.substring(start, end)

with "start" highlighted, so if you start typying, you overwrite "start". If you press tab, the focus goes to the next parameter ("end" in this case), etc. I find if very comfortable not to have to type those "(", ",", ")". But... in Java you can't have pointers to functions. But I think in those cases for D, the IDE can more or less figure out that the user wants just the name: if it is assigning it to a function pointer or delegate (but this is not true all the time).

Anyway, I liked the "=" and "(" method of distinguishing property vs. method. I'll try to implement it. :-)
April 02, 2008
Lionello Lunesu wrote:
> name. And it sounds like it shouldn't suggest more than that; what if I want a ptr to member function?

Then you typed a '&' before the expression you're auto-completing?
Next ›   Last »
1 2 3
Top | Discussion index | About this forum | D home