Author |
Topic |
|
username2481
Starting Member
1 Posts |
Posted - Aug 15 2005 : 1:39:50 PM
|
In C# specifically, just make it throw in a ; automatically at the end of a function call, since you have to do it eventually anyway. Even if it's not the end of your statement you will need it at some point. |
|
kevinsikes
Tomato Guru
USA
271 Posts |
Posted - Aug 15 2005 : 7:32:03 PM
|
What do you mean when you say "at the end of a function call"? Do you mean to add the semicolon each time a funtion name is AutoCompleted or selected from a list box? I can't see this as being useful. You would be erasing the added semicolon on many occasions. Consider when foo() is AutoCompleted in these expressions: bar(foo()) (foo() + 6) / x if (foo() < 10) It would be irritating indeed to have to go back and remove the automatic semicolons from these expressions.
|
Kevin Sikes Infotainment Platform Design Engineer Ford Motor Company |
|
|
briancollins
Senior Member
United Kingdom
39 Posts |
Posted - Aug 16 2005 : 03:33:08 AM
|
But I can see the point of the original post. It would make more sense if the autocomplete added a semicolon after the close paenthesis if (and only if) the caret is at the end of a line.
Brian |
|
|
straightwaytek
Ketchup Master
Canada
66 Posts |
Posted - Aug 16 2005 : 05:10:32 AM
|
Not to insult anyone, but after a while you just get used to using semicolons at the end in both the C++ and C# world (although I've never used nor liked C#). Before programming in C++ I used VB which as everyone knows doesn't use semicolons, so it took a few months to get used to it, but once you commit yourself you should not worry. Also on the part of the software, it would have to be pretty smart, many times function calls are made within conditions ie : if (GetYear() > 2005), or int iShortYear = GetYear() * 10; Maybe it could be done whenever you hit the enter key but I wonder if there would be any performance drops once you hit the enter key because it has to eveulate the line to make sure it needs a semicolon, maybe if they have an option checkbox that might be good. Some programmers have to regularly switch from VB to C++ or C# and they often they make those common mistakes. So yeah, I would have to agree parse the line after someone hits return and if it looks "valid" add a semicolon, but maybe only make it a option that is not on by default.
Sincerley,
James Simpson |
|
|
feline
Whole Tomato Software
United Kingdom
18988 Posts |
Posted - Aug 16 2005 : 4:38:22 PM
|
quote: Originally posted by briancollins
But I can see the point of the original post. It would make more sense if the autocomplete added a semicolon after the close paenthesis if (and only if) the caret is at the end of a line.
Brian
i have to ask, how is this supposed to work?
when i type the line:
int x = foo()| is VAX supposed to say "ah, i am at the end of the line and you have added a function, lets insert a semi-colon"? the problem is i am actually typing:
int x = foo() * 2;|
straightwaytek what you say makes more sense, but i suspect this would only cause problems. as soon as you start to rely on VAX changing your code in subtle ways you risk introducing subtle and hard to track down bugs. if the programmer does this themselves then that is OK, but it is quite a different matter if VAX does this.
on a more practical front, i often move up and down my code when typing lines, so VAX has no hope of knowing when i have finished a line. |
zen is the art of being at one with the two'ness |
|
|
Rain Dog
Ketchup Master
88 Posts |
Posted - Sep 29 2005 : 4:39:29 PM
|
ReSharper handles all of these cases just fine. Perhaps that might motivate someone here? |
|
|
gmit
Whole Tomato Software
Croatia
90 Posts |
Posted - Sep 30 2005 : 03:07:19 AM
|
About semicolon... Why don't automatically insert it after { key is pressed (which is then converted into {}), at the point of enum/class/struct definition?
P.S. I have a feeling that this feature might already exist, but it works very rarely, at least at my place.
|
|
|
feline
Whole Tomato Software
United Kingdom
18988 Posts |
Posted - Oct 01 2005 : 2:46:50 PM
|
Rain Dog how does ReSharper handle my example? i am curious. or does it automatically insert the semi colon, and then it just gets moved along as you type? as a C++ programmer i have never used ReSharper.
gmit this is not a feature i am aware of. if i understand you correctly this would quickly lead to code like:
if(a > b)
{
for(int i = 0; i < 10; i++)
{
if(i % 2)
{
printf("currently i is %d\\n", i);
};
};
};
personally this would drive me up the wall in my C++ code
there is an outstanding feature request that if you type semi colon in the middle of a function call the semi colon is instead placed at the end of the current line. to what degree would this address this need?
case=296 |
zen is the art of being at one with the two'ness |
Edited by - feline on Oct 01 2005 2:49:38 PM |
|
|
briancollins
Senior Member
United Kingdom
39 Posts |
Posted - Oct 04 2005 : 09:26:38 AM
|
quote: Originally posted by feline
quote: Originally posted by briancollins
But I can see the point of the original post. It would make more sense if the autocomplete added a semicolon after the close paenthesis if (and only if) the caret is at the end of a line.
Brian
i have to ask, how is this supposed to work?
when i type the line:
int x = foo()| is VAX supposed to say "ah, i am at the end of the line and you have added a function, lets insert a semi-colon"? the problem is i am actually typing:
int x = foo() * 2;|
straightwaytek what you say makes more sense, but i suspect this would only cause problems. as soon as you start to rely on VAX changing your code in subtle ways you risk introducing subtle and hard to track down bugs. if the programmer does this themselves then that is OK, but it is quite a different matter if VAX does this.
on a more practical front, i often move up and down my code when typing lines, so VAX has no hope of knowing when i have finished a line.
Sorry for the stupidly late response to this.
My idea was that now when I type:
int x = foo(| I get
int x = foo(|) Instead I would propose:
int x = foo(|); In this case the additional semicolon would be (safely) added because the open bracket that triggered insersion of the closing bracket is at the end of the line.
I can't see the downside personally.
Brian
|
|
|
support
Whole Tomato Software
5566 Posts |
Posted - Oct 04 2005 : 10:53:49 AM
|
So when auto-matching paren's , insert ");" if the caret is at the end of line and a special case where it would only insert ")" for lines starting with "if/for/while/catch"? Other special cases? |
|
|
briancollins
Senior Member
United Kingdom
39 Posts |
Posted - Oct 04 2005 : 11:01:43 AM
|
quote: Originally posted by support
So when auto-matching paren's , insert ");" if the caret is at the end of line and a special case where it would only insert ")" for lines starting with "if/for/while/catch"? Other special cases?
That was what I had in mind. And no - I can't think of other special cases - though for C# the list of "block introducing" keywords is different (e.g. "foreach").
Brian |
|
|
Racey
Senior Member
USA
25 Posts |
Posted - Oct 04 2005 : 11:07:26 AM
|
Adding a semi colon following struct/enum...It's already done for you if you use the autotext template. That's good enough for me. If I ignore the template, that's my doing. I dislike when applications second-guess what I'm trying to do.
Adding a semi colon to the end of a line just because I'm typing the closing parenthesis of a function just is too risky. Consider what would happen to someone who types function parameters vertically...
callFunc1(getThis(), getThat();, getTheOther(); );
As much as I dislike this programming style, I wouldn't try to drive someone away from it in this manner.
The benefit of auto-adding a semi colon as far as I can tell is saving me 1 keystroke. The downside is unwanted semi colons that will cause me multiple keystrokes to remove, as well as higher risk of programming error that may not be apparent until run-time.
No Thanks |
|
|
briancollins
Senior Member
United Kingdom
39 Posts |
Posted - Oct 04 2005 : 11:23:27 AM
|
Actually it would be difficult for even this scenario to fail as the ); would be added following the open parent for the outer call, and you would need to do some fairly strange editing for the inner calls to be edited with the caret at the end of line.
My concern is not to save the typing of an extra character. It is that the call is entered with the caret not at the end of line, as WT has already added the close paren. I then need to move my cursor to type in the needed semicolon. and it is this that often gets forgotten. |
|
|
feline
Whole Tomato Software
United Kingdom
18988 Posts |
Posted - Oct 04 2005 : 2:56:51 PM
|
i can see
callFunc1(getThis(), getThat();, getTheOther(); );
happening fairly easily if you typed it like this:
VA inserts the brackets and gives you
callFunc1(|);
press enter and left arrow to get:
callFunc1(| );
and now look up / copy and paste, or even just type in your parameters, and after each one you get a semi colon. i would not call this all that likely, but it is going to happen sooner or later.
does anyone know how ReSharper handles this? i still don't see a clear way to avoid "problem" cases. or does ReSharper just ignore them? |
zen is the art of being at one with the two'ness |
|
|
gmit
Whole Tomato Software
Croatia
90 Posts |
Posted - Oct 06 2005 : 02:45:53 AM
|
Feline, please look my week old post in this thread.
I was talking about inserting semicolons on {} only on some keywords: enum, struct and class.
So, if you would type: enum abc { you would end up with: enum abc {};
|
|
|
Racey
Senior Member
USA
25 Posts |
Posted - Oct 06 2005 : 11:33:36 AM
|
enum, struct and class can be managed through autotext, can't they? In my C++ list, struct and class both came with a semi colon at the end. I didn't have enum in the list, so I added that without any problem. |
|
|
feline
Whole Tomato Software
United Kingdom
18988 Posts |
Posted - Oct 06 2005 : 5:22:08 PM
|
gmit your idea makes sense. at the same time i am inclined to agree with Racey, that autotext is a good solution here. |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|