Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

More with Function Overloading


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 28 April 2004 - 08:44 AM

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]

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3225

Like
Likes
Like

Posted 28 April 2004 - 09:31 AM

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

#3 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 02 May 2004 - 09:32 PM

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)


#4 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 03 May 2004 - 12:01 AM

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?

#5 Andreas Jonsson   Moderators   -  Reputation: 3225

Like
Likes
Like

Posted 03 May 2004 - 05:48 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS