|A new feature of PB5 was function overloading. This is a great new
feature but you may run into problems with PowerBuilder automatic type promotions of
variables and constants.
As described in a previous tip, PowerBuilder only processes
certain Datatypes in its internal virtual machine, although Powerscript allows many more
datatypes. Thus when processing the Datatypes not handled by the virtual machine They are
promoted to the nearest Datatype, this also helps reduce rounding errors in math.
So where is this leading us and how does promotion have any thing to do with function
overloading? Well consider an object with two functions defined:
function_a( int arg_1 )
function_a( long arg_1 )
Then consider the following code fragment:
int li_i, li_j
// call function_a
function_a( li_i )
// Call it again :)
function_a( li_i + li_j )
On the first function call the first function_a gets called because an int is being
passed as the arg, but on the second call the second function_a is being called because PB
promotes the two ints to long's to perform the calculation and creates a long temporary to
store the result which gets passed to the function!