Download MetaTrader 5

MQL5: Only one parameterless constructor?

To add comments, please log in or register
You sell neither signals nor apps? No problem, everyone can make profit!
Max Payne
411
Max Payne 2010.07.14 18:04 

Hmmm, MQL5 does not allow constructors to carry parameters.
Normally, OO-Languages offer multiple types of constructors (with different parameter lists) to be used, in order to (partially) initialize a new object with user-provided values.

IMHO this is a serious omission and a feature that really should be considered for future versions of MQL5!

Cheers!

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
Slawa
Moderator
6841
Slawa 2010.07.14 18:07  

No multiple constructors! And not planned in future

Use initialization member functions 

Max Payne
411
Max Payne 2010.07.14 19:55  

Dear Stringo,

many thanks for your rapid reply!

I can understand that you might not support this in the first version of the language, but I do not understand your resolute "not planned in the future" though.

Overloading of methods is possible (and should be, as otherwise there would not be much merit in calling MQL5 object-oriented),
but why then is overloading of constructors prohibited?

Through this decision orthogonality in MQL5 is sacrificed, whereas especially in language design orthogonality is to strive for!
Here's hoping that the MQL5-Team will still reconsider a number of object-oriented idiosyncrasies for future versions.

Cheers!

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
rgereal
19
rgereal 2012.12.09 10:37  

I couldn't agree more Plymo,

Overloading of constructors is heavily used in OO development. I hope in a future release it gets put in.

EDIT: Correction: You can overload constructors as well as long as you you a parameterless constructur.

Cheers

To add comments, please log in or register