Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Auto type complete on assignment
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

stpeev
Starting Member

1 Posts

Posted - Jan 25 2008 :  07:58:44 AM  Show Profile  Reply with Quote
As you know when writing in C++ it can be quite frustrating to declare types when you assign var names or have loops.
e.g.1:
for (className::innerTypeDef::const_iterator& it = list.begin(); it != list.end; ++it)

e.g.2:
className::innerTypeDef retVal = myObj.DoSometingAndGetResult();

In both cases the type of "it" and "retVal" can be deducted from "list" and the return type of DoSometingAndGetResult(). So it will be nice if I can just write:
for ( it = m_list.begin() ....) or
retVal = myObj.DoSomething ...

and Visual assist to auto complete the proper type declaration for me.

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 25 2008 :  11:00:55 AM  Show Profile  Reply with Quote
A very similar idea came up recently. When using loops to scan across a collection I personally use a VA Snippet that prompts me for the details, to insert the loop.

More generally though, this works well for some types, but not all types. What happens when you are using a pointer type? What about implicit casts?

VA can probably get this right quite often, but there are a lot of edge cases. The question is simply can VA get it right often enough to be reliable and useful?

zen is the art of being at one with the two'ness
Go to Top of Page

znakeeye
Tomato Guru

379 Posts

Posted - Jan 27 2008 :  3:44:14 PM  Show Profile  Reply with Quote
Not a bad idea, but the upcoming standard of C++ already supports this:
for (auto it = v.begin(); it != v.end())

By the way, you used a reference to the iterator. Have never seen that. Is it correct?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 28 2008 :  08:28:42 AM  Show Profile  Reply with Quote
Interesting. I wonder how that handles some of the edge cases, with pointer types and implicit casts.

The obvious problem with that is that current compilers are rather unlikely to support it.

zen is the art of being at one with the two'ness
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jan 28 2008 :  3:54:43 PM  Show Profile  Reply with Quote
Sometimes I move the carret over the symbol, and then using definition field of VAX (located next to the Goto button) to select and send type into the clipboard and then paste into the source It is a good substitute for the "auto" keyword. So VAX already handle this partly (ok, maybe there are some edge cases, I did'nt used for extreme difficult cases yet )

Edited by - accord on Jan 28 2008 3:59:16 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 29 2008 :  09:13:19 AM  Show Profile  Reply with Quote
This is where I am in two minds on this. 90, 95% of the time VA will probably be fine with this. The real question is, will it be fine often enough? Or will the edge / problem cases turn into a support nightmare?

Simple case, what happens here:

int nTest = 2;
foo = nTest * 1.2;
bar = nTest * 3;

I know what I probably want. I probably want a float, or maybe a double, or maybe a #define or typedef for "foo"
And I probably want an int, or long, or unsigned long, or long long for "bar".

I am getting good at dreaming up edge cases

When the item is simply being returned, unmodified, by a function then you *probably* want the return type. But when dealing with pointers and a class hierarchy it is quite common to want some base type, not the actual derived type being returned.

What people want and expect in these conditions is what concerns me.

zen is the art of being at one with the two'ness
Go to Top of Page

znakeeye
Tomato Guru

379 Posts

Posted - Jan 29 2008 :  09:20:28 AM  Show Profile  Reply with Quote
VS 2008 supports "C++0x TR1". Look for this at MSDN:
VS90-VCFeaturePack-Beta-KB945273-x86x64-ENU.exe
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 29 2008 :  12:56:01 PM  Show Profile  Reply with Quote
Interesting. I wonder how much of it our parser supports.

I suspect this could become "interesting".

zen is the art of being at one with the two'ness
Go to Top of Page

znakeeye
Tomato Guru

379 Posts

Posted - Jan 29 2008 :  2:38:05 PM  Show Profile  Reply with Quote
Probably a lot, since you probably use Boost already. As far as I remember, "auto" is the only new keyword.
Go to Top of Page

tandr
Senior Member

43 Posts

Posted - Feb 01 2008 :  3:26:23 PM  Show Profile  Reply with Quote
(auto is very old keyword as a matter of fact, just not used in C++)

Well, till "new" auto will properly supported by some well-known compilers, we probably will have linux rewritten in C#... :)

Anyway - I got an idea - may be to create auto "auto" expander!

imagine you type

Some_Obscure_Heavily_Typedefed<Not_Less_Obscure_Typedef>::const_iterator end;

auto babu = end;|

and then press magic Alt-Ctrl-F13, get a list of choices from fully compacted descriptions to fully expanded typedefs and select first one (fully compacted) and it opens to



Some_Obscure_Heavily_Typedefed<Not_Less_Obscure_Typedef>::const_iterator end;

Some_Obscure_Heavily_Typedefed<Not_Less_Obscure_Typedef>::const_iterator babu = end;|



yeah... I know.

Andrey

Edited by - tandr on Feb 01 2008 3:28:00 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Feb 02 2008 :  08:31:09 AM  Show Profile  Reply with Quote
First point, it wont be long before someone writes:

float auto;
auto = 2.3;

and then wants to know why VA is not replacing auto, or wants to know why VA is replacing auto.

Second point, some list of all possible types is exactly what I am trying to avoid. As soon as you start looking at class hierarchies a certain amount of scanning / considering could be required to figure out every single type that might be an option.

zen is the art of being at one with the two'ness
Go to Top of Page

znakeeye
Tomato Guru

379 Posts

Posted - Feb 09 2008 :  2:38:31 PM  Show Profile  Reply with Quote
Another more general solution would be to add a short key for "copy the type of this variable".

That way, when you want to iterate through a vector or perhaps use a static method of some class, you simple select the variable and press the key combination (ctrl+alt+c?):

vector< complex_type<int> > m_vec;

m_vec // select, ctrl+alt+c
vector< complex_type<int> > // ctrl+v, and you can type "::iterator" or whatever...
Go to Top of Page

jameso
Ketchup Master

United Kingdom
83 Posts

Posted - Feb 11 2008 :  03:28:54 AM  Show Profile  Reply with Quote
I *like* that idea...

James
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Feb 11 2008 :  10:36:35 AM  Show Profile  Reply with Quote
I also like this idea Just to be sure I understand correctly, znakeeye are you talking about VA placing the variable type from the definition field into the clipboard?

Not the exact text from the definition field, but the same information.

zen is the art of being at one with the two'ness

Edited by - feline on Feb 11 2008 10:39:35 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Feb 19 2008 :  09:37:07 AM  Show Profile  Reply with Quote
case=3964

zen is the art of being at one with the two'ness
Go to Top of Page

tandr
Senior Member

43 Posts

Posted - Mar 13 2008 :  10:40:11 PM  Show Profile  Reply with Quote
+1 for copy/paste variables type - it will do the trick. Would be nice to be able not to select variable first if it is the only closest (or cursor is in) variable around though..

Edited by - tandr on Mar 13 2008 10:40:59 PM
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Dec 16 2011 :  1:50:40 PM  Show Profile  Reply with Quote
C++11 auto keyword support is case=13607, and is implemented in build 1862
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000