Discussing the article: "From Basic to Intermediate: Structs (II)"

 

Check out the new article: From Basic to Intermediate: Structs (II).

In this article, we will try to understand why programming languages like MQL5 have structures, and why in some cases structures are the ideal way to pass values between functions and procedures, while in other cases they may not be the best way to do it.

One of the things that leaves many beginners feeling lost when dealing with structures is the question of whether or not values should be passed using structures. Indeed, this is quite an interesting question that, at times, ends up causing more confusion than anything else. Contrary to what some may think, the reason is precisely because we can pass variables by reference, whether to a function or to a procedure. And when this is done, we need to be careful when working with structures in such scenarios.

As someone from the old school, I lived through a time when the C language did not allow data transfer via structures, not directly at least. Today this is possible, but there was a time when we had to use other mechanisms to perform such transfers. In that scenario, the possibilities for error grew as the structure accumulated more variables. But that is the past. Today we have safer mechanisms to perform the same type of transfer. Still, nothing stops you from using older implementation techniques, where the processing speed not the security is the main focus.


Author: CODE X