That's the style! :)

 

Prehistory: Over many years of coding I developed a "personal" style of text formatting(here). My texts have been authomatic already for a long time and I have to use Astyle only when I start working with some "alien" text.

I can explain why I format my texts in this way: the number of tabs (shifted to the right deepening of the text) corresponds to the nesting level. Each opening { starts a new level, so it's on a separate line with the same indentation as the previous text, and all text after it is indented to the right. Each closing } takes the text back one tab. This makes it easy to find paired brackets (they should be in the same position vertically and the number of times the Tab key is pressed corresponds to the nesting level of the text. The internal + - > < < are punctuated with spaces, so that the text doesn't blend into a solid mush. To me, this makes sense and makes sense.


Now the story: Yesterday I received the source code of ml5 with some strange (from my point of view) formatting: braces are shifted to the right, inside the text by 2 positions, and the text inside them is also to the right, but only by one position. I tried to use tabulator to get to the same position where there is an opening { in order to put a closing } - did not work.

Can someone (maybe the developers) explain the logic of Metaeditor5 formatting?

Here is a piece of code from MACD Sample.mq5 in their way and in my way:

Styler5                                  -|- Мой стиль
-------                                  -|- ---------
bool CSampleExpert:: LongModified()       -|- bool CSampleExpert:: LongModified()
  {                                      -|- {  
   bool res=false;                       -|-   bool res = false;
//--- check for trailing stop            -|-   //--- check for trailing stop
   if( InpTrailingStop>0)                 -|-   if ( InpTrailingStop > 0)
     {                                   -|-   { 
      if( m_symbol.Bid()- m_position. Price -|-     if ( m_symbol.Bid() - m_position. Pric
        {                                -|-     {
         if( m_position. StopLoss()< m_symb -|-       if ( m_position. StopLoss() < m_symb
           {                             -|-       {
            double sl= m_symbol.Bid()- m_a -|-         double sl = m_symbol.Bid() - m_a
            double tp= m_position. TakePro -|-         double tp = m_position. TakeProfi
            //--- modify position        -|-         //--- modify position
            if( m_trade. PositionModify( Sy -|-         if ( m_trade. PositionModify( Symbo
               printf("Long position by  -|-           printf(" Long position by % s to
            else                         -|-         else
              {                          -|-         {
               printf("Error modifying p -|-           printf(" Error modifying positi
               printf("Modify parameters -|-           printf(" Modify parameters : SL
              }                          -|-         }
            //--- modified and must exit -|-         //--- modified and must exit fro
            res=true;                    -|-         res = true;
           }                             -|-       }
        }                                -|-     }
     }                                   -|-   } 
//---                                    -|-   //---
   return( res);                          -|-   return( res);
  }                                      -|- }
 

ForexTools писал(а) >>

as it turns out, this is how Metaeditor5 formats its Styler command.

Can someone (maybe the developers themselves) explain to me the logic of Metaeditor5 formatting?

I join the question, I've always wondered too.

 

Don't look for logic where there is none. You'd better make a bug report.

=)

 

Always raised questions too. :(

I do, however, stick to a Java-like style.

 
sol >> :

Don't look for logic where there is none. You'd better make a bug report.

=)

Read Help, because it's all there:


 
sol >> :

Better make a bug report.

It's not a bug after all (pure and simple). It's just "they see it that way" :)

I want to understand the logic first, if there is one.

 
Rosh >> :

Read the Help, because it says it all:

the Help says HOW to do it, but it does not say WHY it is considered correct, convenient, efficient, ....

for such operation it would be necessary to make styler options (for example, look at documentation on Astyle)

opening brackets:

- shift to the right: number of spaces

- line break: before or after

etc.

 
ForexTools >> :

I want to understand the logic first, if there is one.

The logic is that the code is aligned to the nesting level. There is no disagreement here, as we can see.

But opening and closing parentheses are not code, but design elements, so they are slightly outside the code by one character.

 

Rosh писал(а) >>

The opening and closing brackets, on the other hand, are not code but design elements, so they protrude slightly beyond the code by one character.

It seems to me that block brackets are an important part of the code and highlight a logical or functional block. So why shouldn't they be positioned so that they actually perform that function? We won't talk about spaces around operators etc. just yet.

 
Rosh >> :

The logic is that the code is aligned to the nesting level. There is no disagreement here, as we can see.

There is a difference of opinion about what you think and what other users find convenient for themselves ;)

I think the problem is EASILY removed by additional styler settings. I'm sure it's NOT the hardest thing to do.

 

Thanks TheXpert, I somehow didn't even notice this "passage"

А вот открывающие и закрывающие скобки не являются кодом, а являются элементами оформления

well, don't pull the excuse that it was somehow done and now you have to at least explain it ;)

The design elements are comentaries, you can remove them without any loss of functionality!!! Try to remove just one such "element" (I mean } ) - where will the compiler send you? :))))

Reason: