This simplification may be due to the fact that an operator name cannot be qualified (prefixed by its namespace name) and could therefore be only imported (from its namespace) by 'Using'.coderJeff wrote:I think you will find some odd behaviours when it comes to operators. They are defined in the global namespace even if the declaration is in a namespace. Which can be confusing. I believe there is improvements needed for operators.
But the global namespace is always a scope candidate when looking-up for an overload operator name from another scope, because this operator name cannot be used with a qualifier prefix but always as an unqualified name (seen from the operator call, the global namespace is either the current namescape or a parent namescape):
Code: Select all
Namespace M
Type T Extends Object
End Type
Operator Abs(Byref t0 As T) As String
Return "operator Abs()"
End Operator
Sub test()
Dim As T t0
Print Abs(t0)
End Sub
End Namespace
Namespace N
Sub test()
Dim As M.T t0
Print Abs(t0)
End Sub
End Namespace
M.test()
Dim As M.T t0
Print Abs(t0)
N.test()
Sleep
Code: Select all
Type T Extends Object
End Type
Namespace M
Function _abs(Byref t0 As T) As Integer : Return 1 : End Function
Operator Abs(Byref t0 As T) As Integer : Return 2 : End Operator
End Namespace
Namespace N
Function _abs(Byref t0 As T) As Integer : Return 3 : End Function
Operator Abs(Byref t0 As T) As Integer : Return 4 : End Operator '' duplicate definition
End Namespace