Archived

This topic is now archived and is closed to further replies.

More with Function Overloading

This topic is 5006 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Beta2 seems to be working fine, except that I'm having one problem. I noticed this in beta1, but never tried it before that. Suppose in a script I have three functions: catch(float) catch(double) catch(int) I can call the functions by doing 'catch(10.0)' or 'catch(10.0f),' but when using 'catch(10)' the compiler will only match 10 with an unsigned int (using 'catch(int(10))' works though). Building... Compiling function 'main' in "scripts\main.script" Error : (6, 1) Multiple matching functions to 'catch(const uint)' void catch(float) void catch(double) void catch(int) Completed. (errors: 1, warnings: 0) If I add a fourth function that takes an unsigned int parameter then this problem goes away, but it seems that 10 should match as an integer if that is the only choice. [edited by - Desdemona on May 3, 2004 4:35:28 AM]

Share this post


Link to post
Share on other sites
You are correct. A constant uint, should be implicitly converted to int, and normally it does. I''ll verify what''s wrong with the code. It will probably be working for the next beta.



__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game

Share this post


Link to post
Share on other sites
Having some more problems with overloaded functions (beta4):
void CreateBox(bstr name, float x, float y, float z)
{ CreateBox(name, x, y, z, 25.0f, 25.0f, 25.0f); }

void CreateBox(bstr name, float x, float y, float z, float dx, float dy, float dz)
{}

Building...
Parsing: "scripts\config.script"
Error : (146, 6) Name conflict. ''CreateBox'' is a function.
Compiling function ''CreateBox'' in "scripts\config.script"
Error : (144, 3) No matching functions to ''CreateBox(bstr&float&float&float&const floatconst floatconst float)''
Completed. (errors: 2, warnings: 0)

Share this post


Link to post
Share on other sites
I guess it is happening whenever I try to declare an overloaded function inside of a script file. I was just reading the manual and it said that functions can''t share the same name with other functions. So does this mean that the only overloading allowed is through the asIScriptEngine''s register methods?

Share this post


Link to post
Share on other sites
Yes, scripted functions currently don''t allow function overloading. I simply haven''t had the time to implement it yet.


__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game

Share this post


Link to post
Share on other sites