Namespaces do not work for interfaces.
Aside from that: your example might become stressful if you work on
combinations:
namespace string_string;
namespace string_number;
namespace number_number;
namespace number_string;
string_string function sum(a:String, b:String): String;
string_number function sum(a:String, b:Number):String;
number_string function sum(a:Number, b:String):String;
number_number function sum(a:Number, b: Number): Number;
Also having to use those methods is almost of no joy:
myObj.string_string::sum("a","b");
or
use string_string;
myObject.sum("a","b");
and this is just for simple types, imagine what it looks like for
complex types with namespaces
namespace org_project_type_MyType__String;
Again: I am living a little in a theory space, so: Yes, you can do that
but doing it properly is really, really uncomfortable.
yours
Martin.
On 17/01/2012 00:46, Matthew Poole wrote:
You can always just use a custom namespace to acieve overloading. e.g.
namespace addString;
namespace addNumber;
addString function Sum(a:String,b:String):String
{
return a+b;
}
addNumber function Sum(a:Number,b:Number):Number
{
return a+b;
}
On 16 January 2012 15:33, Rui Silva<f...@rduartes.net> wrote:
From: "Martin Heidegger"<m...@leichtgewicht.at>
(...) Also
the if checks for the type cost performance.
yours
Martin.
I believe that the example stated there were no difference in the code that
sent any of the types. If that was not the case, I'd keep the descriptive
long method names.
Agree on the type safety when you use *, but I would only use that when any
type is absolutely admissible, or I'd keep the descriptive long method
names.
Rui