19 February 2019

Function Overloading in AL with Option and Integer


We never had the luxury of overloading a function in C/AL, but with the AL we have that ability. Which means you can use the same function name with different parameters. 

This blog post is about a small glitch in the function overloading in AL and I will write a separate blog post about function overloading and its implementations (Excited about it). 


I had below function signatures in my code and each of these functions is called from 6 different places. 
 procedure InsertData(Code: code[10]; lDelimiter: Option Comma,Tab,SemiColon,"Fixed")  

 procedure InsertData(Code: code[10]; configType: Integer; Config: Boolean)  

However, I noticed that the second function got 12 references from the function calls and the first one got none (should be 6 each).  




Reason for the 
glitch: Option is also passed as an integer to the function so compiler sees both the function signatures as same. 


What I assume is, even though the AL compiler does not give an error during compiling of the code it still sees both the function signatures as the same. That is why it is referencing all the function calls to one function.

** In order to replicate this, function signature needs to have the same number of parameters.

** Thank you Stephen Gichure for helping me to prepare this blog post.

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara

No comments:

Post a Comment