Go Down

Topic: Interest in overhauling the IDE user interface? (Read 19 times) previous topic - next topic

Boffin1

#40
Sep 12, 2012, 08:11 am Last Edit: Sep 12, 2012, 08:20 am by Boffin1 Reason: 1
Yes , it would need to be deselected when not needed, as it would look like a Xmas tree, which is what I think would show which goes with which.

Or another way of showing the pairs, is to be able to select a way to have each pair a greater  indent from the left margin ( and the text within them )
I sometimes do this anyway, so that I can see each section,  you would have to be able to return to normal .....


void loop ()
{
if ( cost > x )
   { serialPrint ( cost );  if ( cost > 2x )
       {  digitalWrite ( ledPin, HIGH );
       }
    }
}
With my mobile phone I can call people and talk to them -  how smart can you get ?

eried

#41
Sep 12, 2012, 09:54 am Last Edit: Sep 12, 2012, 09:56 am by eried Reason: 1
I know some people like (not sure why, maybe they get used to this using green-terminal displays with few rows of text)
Code: [Select]
function( ) {
}


But I like:
Code: [Select]
void loop ()
{
 if ( cost > x )
 {
   serialPrint ( cost );  
   
   if ( cost > 2x )
     digitalWrite ( ledPin, HIGH );
 }
}


Just because it is pretty nice to visually match curly braces as you want, your example for me seem extremelly confusing at first glance. The only problem is if the function is  very long, you lose the "tab" position reference. At least in Visual Studio (I guess those guys do lots of usability test) the matching brace gets highlighted and when you type "}" the indentation is fixed.
My website: http://ried.cl

Graynomad

#42
Sep 12, 2012, 09:56 am Last Edit: Sep 12, 2012, 09:58 am by Graynomad Reason: 1
Most (all?) IDEs have some form of match ({[ function. Normally just place the cursor on one and it highlights the matching one. Sometimes you ^B (for example) to move the cursor to its match.

However it's done it's a very useful feature.

EDIT: We all have a preferred method when it comes to {}, it's not the job of an IDE to enforce that, or even help probably. If you use TABs properly the indentation is easy to follow. An editor that handles block in/outdenting makes life a lot easier in this regard.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Boffin1

Quote
But I like:



Code: [Select]
void loop ()
{
  if ( cost > x )
  {
    serialPrint ( cost ); 
   
    if ( cost > 2x )
      digitalWrite ( ledPin, HIGH );
  }



Shouldnt there be another pair of curly braces after the 2x ?
With my mobile phone I can call people and talk to them -  how smart can you get ?

Graynomad

#44
Sep 12, 2012, 10:58 am Last Edit: Sep 12, 2012, 11:01 am by Graynomad Reason: 1
If you are referring to this

Code: [Select]
if ( cost > 2x )
      digitalWrite ( ledPin, HIGH );


Then no, braces are not required. They are however highly recommended as leaving them out can lead to subtle bugs later. For example you add a line of code.

Code: [Select]

if ( cost > 2x )
      x++;
      digitalWrite ( ledPin, HIGH );


Now of course, despite the indenting, digitalWrite() gets called regardless of the "if" result. This can be difficult to spot because your brain "reads the indenting" and skips over the fact that the two lines are not in a code block.

Another example

Code: [Select]

#define INC_STUFF   x++; y++;

if ( cost > 2x )
      INC_STUFF;


x++  is conditional, y++ is not.

This is bad coding on two fronts, the {} we're talking about and having a non-atomic #define.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up