MQL5: Only one parameterless constructor?

 

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
 

No multiple constructors! And not planned in future

Use initialization member functions 

 

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
 

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