Skip to main content
gamedev.net
🔒 Locked

More with Function Overloading

Started by Desdemona 3 replies 1.3k views
Original Post
Desdemona
Desdemona
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]
WitchLord
WitchLord
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
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
Desdemona
Desdemona
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)
Desdemona
Desdemona
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?
WitchLord
WitchLord
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
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.