Download MetaTrader 5

MQL5 should permit circular class dependency

To add comments, please log in or register
Enrico Ballardini
1714
Enrico Ballardini  

Like a regular C++ compiler, MQL5 doesn't allow circular class dependency... and that's just... regular.

 

Well, dear Metaquotes,

since you introduced a variety of modification in your own language,

such as dynamic arrays, automatic memory allocation, function templates, and so on... why don't you consider to permit  circular class dependency?

I must admit it takes a lot of time to me to avoid circular class dependency when designing classes structure... and that's very annoying.

 

I know I can define a class name before defining the full class structure... and that's just not sufficient... think to Java: that's what I'm talking about. 

Create your own Market Watch using the Standard Library Classes
Create your own Market Watch using the Standard Library Classes
  • 2010.12.28
  • Dmitriy Skub
  • www.mql5.com
The new MetaTrader 5 client terminal and the MQL5 Language provides new opportunities for presenting visual information to the trader. In this article, we propose a universal and extensible set of classes, which handles all the work of organizing displaying of the arbitrary text information on the chart. The example of Market Watch indicator is presented.
Oyebimpe Adeola Ojetunde
493
Oyebimpe Adeola Ojetunde  
Good comments. I am looking forward also to heard from metaquotes
Heinz Traub
314
Heinz Traub  

I think you mean class forward reference but that is as you said defining the class name before the full implementation. Can you give a sample code?

Enrico Ballardini
1714
Enrico Ballardini  

Here is the example: 

class Context
{
public:
void doSomethingOnStuff (Stuff* stuff)
{
stuff.doSomething (GetPointer (this));
}
};



class Stuff
{
public:
void doSomething (Context* c)
{
Print ("Doing in context...");
}
}

  

Compiler Error: 'Stuff' - Declaration without type 

Enrico Ballardini
1714
Enrico Ballardini  
Is indentation an option in this forum?
Heinz Traub
314
Heinz Traub  

First of all, couldn't agree more about indentation. I waste more time making code more readable than writing the code itself. However i don't think implementation of tab characters are possible because it would cause the text control to leave focus on most operative systems, so i have never complained about it until now. Don't know if it is possible to use CSS styling to achieve the results.

About the example code, it is indeed a class forward reference and it is solved using the same thing you said:

class Stuff; // Declaring the class name here does the thing.

class Context
{
    public:
    void doSomethingOnStuff (Stuff* stuff)
    {
        stuff.doSomething (GetPointer (this));
    }
};



class Stuff
{
    public:
    void doSomething (Context* c)
    {
        Print ("Doing in context...");
    }
};
// Lots of spaces for indentation by the way.

So, i still don't understand what you mean by circular class dependency.

phi nuts
2181
phi nuts  
lamemind:
Is indentation an option in this forum?

Please edit/write your codes with SRC button, like TripleHeinz did.

 

Sadly, nope, there's no indentation in the forum, it's up to user's writing style, https://en.wikipedia.org/wiki/Indent_style.

You can always copy paste from MetaEditor ;) 

Enrico Ballardini
1714
Enrico Ballardini  

Sorry for the late answer

Print ("Yo, thanks phi.nuts");


TripleHeinz, you're right. You don't understand cause I made a mistake ;)

And yet, I have some disappointment about MetaEditor.

At my job I use Netbeans IDE with Java: there is no level of comparison. I know I can sound boring or freakish and I don't care. I know metaquotes can do a better product!

  1. Why only 64 bytes in path length? Just try to consider I'd like to give some structure to my code... To me, this limitation is annoying. Seriously: is this a life saver feature or something?
  2. by declaring classes before their implementation everything compile correctly, yes... But i lose the autocompletion feature... it's just like a regular text editor with a "compile plug-in".
  3. The styler can't be customized, and I don't like mql5 indentation standard (can I say this?)
  4. There are no smart shortcuts (such as "toggle line comment" CTRL+SHIFT+C, which I love in netbeans)
  5. There is no autocompletion in the #include construct.
  6. There is no wildcards in the #include construct.


My list could be much much long...

Just eih: it's 2013!

To add comments, please log in or register