[antlr-interest] overloaded functions
Sohail Somani
sohail at taggedtype.net
Wed Jan 4 10:53:27 PST 2006
On Wed, 2006-01-04 at 08:22 -0500, Bryan Ewbank wrote:
> Anyone have references on algorithms to disambigute calls of
> overloaded functions? I'm familiar with how C++ does it, but am
> looking for other options.
>
> To make it more complex (ugh), the language allows name/value pairs
> for parameters as well as positional parameters. Hence you might see:
> f(10, 2.0)
> f(10, b=2.0)
> f(a=10, b=2.0)
> all of which are equivalent functions.
Doesn't your language tell you how it does overloading? As for the
example you show, I would suggest that you get all function calls into
an intermediate form utilizing the function declaration (if your
language allows this). For example:
f(10,2.0) => f arg[0]=10 arg[1]=2.0
f(10,b=2.0) => f arg[0]=10 arg[indexof(b)]=2.0 <- requires declaration
...
If you have no declaration, you'd have to do it at module linking time
(I imagine!)
More information about the antlr-interest
mailing list