You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Java is also not running outside of its virtual machine, there you will have the same problems, you cannot make a dll that can be loaded and called from a C program.
If you like C# then you will also like ObjectPascal (the type safety, the strictness, the entire philosophy behind it, except the VM thing). After all the designer and chief architect of C# is the same person who once created Turbo-Pascal and Delphi (ObjectPascal) and it shines through. In some regards C# is like ObjectPascal with (ugly but nowadays hip) C syntax.
For interfacing directly with the machine and with C-APIs (like it is needed for MetaTrader) and still using a language as powerful as C# there are not many alternatives to ObjectPascal. Some say C++ is equally powerful (and can of course also be used instead of OP) but it is clearly not as elegant, has many inconsistencies and is so error prone that only true experts can truly master it.
.... the return inside a function will make it return to the place the function was called from.
This is the crucial distinction 7bit: I'm talking about invoking a completely different function, subroutine or even imported code, entire sub-routines &/or functions OUTSIDE of the entire current function. A conceptual example:
I'm in a function that takes place from line 100 to line 20, but I want to invoke something that fall outside of THIS scope. Perhaps an entirely different function that is in lines 50 to 60. <=-This doesn't fit the parameters and example above which is what I am asking about It is a 100% substitute of the old gosub/return and additionally the function allows for passing values and returning values.
You CAN have multiple return statements within the same function and you can also break out of loops with break ....
Understood
But I keep getting told about how I can move around within the scope of a specific function, which I understand. But this is NOT what I am asking about at all and stated at the start of all of this.
So as to 'exceptions' then I guess you can call them that if you wish. As I stated, I'm trying to find a 'work around' to add and utilize the functionality of functions such as: GoTo, GoSub (outside of the CURRENT function) etc that does not exist as a function directly within MQL4. By your responses, most of you know of and understand these programming distinctions, but are not addressing the actual question asked.
FourX:
I'm in a function that takes place from line 100 to line 20, but I want to invoke something that fall outside of THIS scope. Perhaps an entirely different function that is in lines 50 to 60.consider this:
Now what will happen? Lets start with main(), I will explain all steps during execution (comments are in green, instructions are black):
Can you see it? the foo function needs a local stack frame of 8 bytes plus return address and the bar function only 4 bytes plus return address. Their return statements have this built in by the compiler at compile time already, they pop different amounts of bytes from the stack, you cannot use one return to do the job of the other, each one works only for the function it was compiled for.
These old languages that had GOTO across the entire program did not have local variable scope and the only thing you had to get right was to match the number of GOSUB and RETURN to be equal, all their returns did only pop the return address and nothing else, all the returns behaved exactly the same. But now we have a lot of differently sized "GOSUB"s (each one pushes different amounts onto the stack) and also many different returns which pop different amounts from the stack. And we have local variables on the stack. This just cannot work, no matter what crazy things you try to build into the compiler.
You could theoretically GOTO within the *same* function (and some languages allow this) but you cannot show me one piece of code where this would actually lead to more elegant and easier to understand and more maintainable code than proper structured programming. All it would do is produce a horrible mess. Nobody needs this, so it is not implemented.
We all already know that MQL4 doesn't have such native functions as a GoTo OR a 'GoSub -=> ReturnFromGoSub.' There is no dispute about that. This has now turned into repeated explanations and examples of the fact that MQL4 doesn't have such native functions. No argument there. That isn't what this thread is about and it never was. So can we please stop arguing about what we already know and agree on?
We know that these are valid functions in other programming languages and can be very useful.
The whole point of this is to find out IF we CAN simulate and utilize them with what IS available in MQL4?
For example, a valid function completion of the second case in the first sentence of 'GoSub -=> ReturnFromGoSub' would be to: Return to point of the program that the GoSub was called and return the values from GoSub to the calling point in the program.
For example, a valid function completion of the second case in the first sentence of 'GoSub -=> ReturnFromGoSub' would be to: Return to point of the program that the GoSub was called and return the values from GoSub to the calling point in the program.
FourX:
'GoSub -=> ReturnFromGoSub' would be to: Return to point of the program that the GoSub was called and return the values from GoSub to the calling point in the program.
FourX if you are learning mql4 while still have your mind is still in BBC Basic think defproc and proc and forget GoTo and GoSub.
I had a BBC micro in the early 80s ....ahhhh i still remember the joys of trying to get programs to load off its cassette tape drive :( we used to write programs in BBC Basic
FourX if you are learning mql4 while still have your mind is still in BBC Basic think defproc and proc and forget GoTo and GoSub.
I had a BBC micro in the early 80s ....ahhhh i still remember the joys of trying to get programs to load off its cassette tape drive :( we used to write programs in BBC Basic
LOL . . . I had an Acorn Electron . . . when it was hot it wouldn't read stuff off tape I had written when it was cold and visa versa . . . those were the days. ;-)
Yes they were the days alright :) twisting a bent screwdriver on that little screw by the tape heads while repeately thumping the side of it haha