Oxygen Basic
Information => Development => Topic started by: jcfuller on January 15, 2018, 06:17:47 AM
-
Charles,
Does OxygenBasic have overloaded functions similar to FreeBasic?
I only found one reference in the MathComplex.inc file, but no examples of use with simple functions that have the same name but different parameters.
James
-
It looks like this was a duh question as I just created different functions with the same name but different parameters and it compiled and ran fine without any "OVERLOAD" keyword!!
Fine work Charles.
James
-
As an alternative to function overloading, there is also default parameters, which can save function duplication:
function f(int a=1, b=2, string c="ok") as int
...
end function
You can call such a function in the usual way, but you may also specify parameter assignments individually:
f( b=42, c="X" )
-
@Charles Pegge
I thought that you mentioned at one time that you would take-out function overloading, it seems function overloading is still supported, can you also overload math operators?
-
Hello jack,
Selecting the right function, and converting parameters to match the type where necessary, is extra work for the compiler. However, occasionally there are no easy alternatives, like getter and setter functions.
I'm keeping very quiet about operator overloading. I am still working on it to get the best performance for both high level and assembler level operations. A type can have its own set of operations, based on macros, so the overhead of calling operator functions is avoided.
-
thank you :)