Author Topic: Another small issue with parameter matching...  (Read 955 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Another small issue with parameter matching...
« on: January 12, 2019, 10:22:38 PM »
If it doesnt find an exact match, it just takes the last one, instead of the one that matches the most:

Code: [Select]
FUNCTION sources() as wstring
    wstring ss = "source"
    return ss
END FUNCTION

function handler(wstring ss, wstring d = "unicode!") as long ' this one should be used....
    print "UNICODE HANDLER: " + ss
end function

function handler(string ss, string d = "ANSI!") as long ' instead uses this one.
    print "ANSI HANDLER: " + ss
end function

handler sources()

Brian Alvarez

  • Guest
Re: Another small issue with parameter matching...
« Reply #1 on: January 12, 2019, 10:31:39 PM »
Here is another example, i think the isssue is more evident, because it has 2 ANSI strings, yet, the unicode handler is picked:

Code: [Select]
FUNCTION sources() as string
    string ss = "source"
    return ss
END FUNCTION

function handler(string ss, string d = "ANSI!") as long
    print "ANSI HANDLER: " + ss
end function

function handler(wstring ss, wstring d = "unicode!") as long
    print "UNICODE HANDLER: " + ss
end function

handler sources(), "ansi string!"

Charles Pegge

  • Guest
Re: Another small issue with parameter matching...
« Reply #2 on: January 12, 2019, 11:11:24 PM »
There is a conflict between function-overloading and default parameters. When evaluating a match, function-overloading only works with definite parameters.