incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Heidegger>
Subject Re: AS3 Enhancements: method overloading. Why do people want this?
Date Mon, 16 Jan 2012 15:56:21 GMT
Namespaces do not work for interfaces.

Aside from that: your example might become stressful if you work on 

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:


use string_string;

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.


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<>  wrote:
>>> From: "Martin Heidegger"<>
>>> (...) 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

View raw message