Wishes for MQL5 - page 38

 
SK. писал (а):

I'd also like a break from if().

I haven't seen something like that in popular programming languages...


komposter:

I came across some code similar to this one:

while ( true )
{
   if ( condition1 )
   {
      Alert("1");
      break;
   }
 
   if ( condition2 )
   {
      Alert("2");
      break;
   }
 
   break;
}
I think that's what's needed ;)

Don't they wear classics this spring? :-) Let's see a dress made of nothing but IF's:


if (condition) { // ЭТО IF, КОТОРЫЙ НУЖНО BREAK'НУТЬ ОДНИМ ИЗ НЕСКОЛЬКИХ УСЛОВИЙ
 
  // ...тут делаем че-нить полезное...  
 
  if (!break_condition1) {
 
    // ...продолжаем делать полезное...  
 
    if (!break_condition2) {
 
      // ...продолжаем делать полезное...  
  
    }
  }
}
 
ds2:

Aren't they wearing classics this spring already? :-) Looking at a dress made from just IF's:

Don't they read the discussion of the question before answering it anymore? ;)
"Ordered" exactly a break from an if, not an infinite tree "!break_condition".

 
ds2:
SK. wrote (a):

I'd also like a break from if().

I haven't seen something like that in popular programming languages...

О. That's it, right on the money.

The positive statement in this statement is that if it's not in other languages, it's bad, it means that it's something foreign and unnecessary.

In my opinion that is not the case at all. We should rather look for harmony in popularity. Fashion is nothing but a vivid confirmation of the herd effect. Trendy things are rarely really useful or comfortable. Junk goods have never weighed on the minds of the common man.

Just don't take it personally, please.

The break and continue is just a little technical tool.

If you look carefully at many programs, you will find that the need to get out of a complex construct does not arise only in the case of loops or scrolls for the simple reason that complex constructs are not formed only on the basis of loops and lists. They are formed on the basis of ifs as well. So a controlled transition to an external closing parenthesis would be useful.

That's not the point. What I wanted to say is that this "think": "I don't need it" is a very powerful obstacle to development. It is much more useful, in my opinion, to be in constant search and not to reject from consideration of new decisions, if they have at least a grain of utility.

 
SK. писал (а):
ds2:

I haven't seen anything like this in popular programming languages...

...

break and continue is just a little technical tool.

...

The idea is great, I think everyone will be happy if break for if is different from break for while (breakif, breakwhile, breakfor, breakcase for example)

 


karakuts At first I wanted to ask why they should be differentiated, but then I realised. It's easier and more logical to add just a breakif.


P.S. Started up with the editor, I've killed everything - my apologies.

 
karakuts:

The idea is great, I think everyone will be happy if break for if is different from break for while (breakif, breakwhile, breakfor, breakcase for example)

By the way, here is a development of the idea. Making a distinction in breakfor, breakcase, etc. would be useful in itself. It would obviate the need to execute (and earlier code) a lot of checks to exit a complex nested construct. Same for continue.

 

It is even easier to introduce a single goto, to avoid a cacophony of different breaks: even Wirth, who criticized it, left it in his Pasquale. The goto, by the way, has a natural mechanism for marking a transition mark, which is easy to make mnemonic.

 
Mathemat:

It is even easier to introduce a single goto, to avoid a cacophony of different breaks: even Wirth, who criticized it, left it in his Pasquale. Goto, by the way, has a natural mechanism for marking a transition mark, which is easy to make mnemonic.

I haven't used unconditional jump operator for about 10 years, there were programming languages (high level at that time) where you can't do without it, but now it's atavism! :)

P.S. I'm in favour of keeping it, four GOTO's bring back fond memories :)

 
Mathemat:

It is even easier to introduce a single goto, to avoid a cacophony of different breaks: even Wirth, who criticized it, left it in his Pasquale. Goto, by the way, has a natural mechanism for marking a transition mark, which is easy to make mnemonic.

Wonderful. We have such a cacophony of frogs at the river in summer!:) I'll call them breakers from now on:)

 

One more thing about externs.

It would be convenient to make "conditional" variables - variables whose visibility and possibility to use depend on other extern variables.

For example, there is a function "Filter by parabolic", which is enabled by corresponding boolean variable. It has parameters - "step" and "maximum" of the parabolic indicator. So, the parameters should be visible and available for editing only when "Parabolic Filter = true".

Example 2: Expert Advisor on intersection of 2 averages. Period of slow average must be limited by period of fast average (and vice versa). I.e. if fastPeriod = 20, slowPeriod must not take values lower than 21.

Reason: