Archived
This forum has been archived. Please start a new discussion on GitHub.
Overloading functions in slice
I am trying to understand Ice and the underlying architecture and would appreciate any help in the following matter
My slice file is
module com
{
module xxx
{
module foo
{
module service
{
interface SomeService
{
bool isValidTradeDate(string country, string date ) ;
bool isValidTradeDate(string country, string date, string dateFormat ) ;
};
};
};
};
};
As you can see I am trying to overload the function isValidTradeDate by passing dateformat as extra parameter
When I run
c:\Ice-3.1.0\bin\slice2java --output-dir c:\kill\src someservice.ice
I get the following error
someservice.ice:12: redefinition of operation `isValidTradeDate' as operation `isValidTradeDate'
How do I overload a function? Is it supported?
If this is a stupid question please educate me.
Thanks
My slice file is
module com
{
module xxx
{
module foo
{
module service
{
interface SomeService
{
bool isValidTradeDate(string country, string date ) ;
bool isValidTradeDate(string country, string date, string dateFormat ) ;
};
};
};
};
};
As you can see I am trying to overload the function isValidTradeDate by passing dateformat as extra parameter
When I run
c:\Ice-3.1.0\bin\slice2java --output-dir c:\kill\src someservice.ice
I get the following error
someservice.ice:12: redefinition of operation `isValidTradeDate' as operation `isValidTradeDate'
How do I overload a function? Is it supported?
If this is a stupid question please educate me.
Thanks
0
Comments
-
Hi Sameer,
Slice does not support overloaded operations because not all target languages support function overloading (such as Python). You'll need to use a different name for each version of the operation.
Take care,
- Mark0 -
Mark,
Thanks for the prompt reply
Regards0 -
mes wrote:Hi Sameer,
Slice does not support overloaded operations because not all target languages support function overloading (such as Python). You'll need to use a different name for each version of the operation.
Take care,
- Mark
In addition, allowing operation overloading would also make the Ice protocol much more complicated, because you could not only simply transfer the operation name, but would have to transfer the signature of the operation as well, so that the server knows which version of the operation to call.0