Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: jcfuller on February 13, 2018, 04:03:33 AM
-
Charles,
Will optional parameters for overloaded functions be offered in the future or are they supposed to work now?
Your overloaded example works fine but adding optional causes only the last foo function to be called.
% filename "overloading2.exe"
uses rtl64
'FUNCTION OVERLOADING
'====================
function foo (long v, optional string os) as string
print os
return "long " v
end function
function foo (double v, optional string os ) as string
print os
return "double " v
end function
function foo (string v, optional string os) as string
print os
return "string " v
end function
long l=42
double d=42.5
string s="43"
print foo (l,"l")
print foo (d,"d")
print foo (s,"s")
Another related question
Is the keyword "optional" optional :) with functions that have default parameters?
I noticed in some of your examples you just assign a value:
Function abc(sys i,sys n=17) As sys
Function abc(sys i,optional sys n=17) As sys
James
-
Hi James,
This release fixes the function overloading / optional param problem.
Parameter default values, however, are not compatible with function overloading, but you can combine them with optional where the functions are not overloaded.
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenProgress.zip
PS:
I've added hibyte and lobyte as core keywords