G
Guest
Greetings.
I have some questions that I would like to clear out.
1. Why do operators have to be static? (This question relates to the
language specification)
2. More importantly, couldn't there be operators that were tranlated at
compile-time to "normal" methods?
For example:
bool operator ==(T something);
would be translated to:
bool operator_equal(T something);
At code it would be used as:
T a = new T();
T b = new T();
if(a == b)
// ...
and it would be translated as:
T a = new T();
T b = new T();
if( a.operator_equal(b) )
// ...
This translation would permit using overloaded operators in VB .NET and J#,
and maintain the C++ operators.
Plus, the Object class could have the == operator overloaded as:
public bool operator ==(object obj)
{
return Equals(obj);
}
The most important question is: Does someone know why wasn't this feature
placed in the CLS?
I don't see how it would break type safety.
Thank you for your attention.
I have some questions that I would like to clear out.
1. Why do operators have to be static? (This question relates to the
language specification)
2. More importantly, couldn't there be operators that were tranlated at
compile-time to "normal" methods?
For example:
bool operator ==(T something);
would be translated to:
bool operator_equal(T something);
At code it would be used as:
T a = new T();
T b = new T();
if(a == b)
// ...
and it would be translated as:
T a = new T();
T b = new T();
if( a.operator_equal(b) )
// ...
This translation would permit using overloaded operators in VB .NET and J#,
and maintain the C++ operators.
Plus, the Object class could have the == operator overloaded as:
public bool operator ==(object obj)
{
return Equals(obj);
}
The most important question is: Does someone know why wasn't this feature
placed in the CLS?
I don't see how it would break type safety.
Thank you for your attention.