Menu

#315 Member operators

open
nobody
None
2023-04-01
2020-11-06
Rule
No

Please allow unary and binary operators to be members of a type, because often they need to access private members. For example:

Type MyType
Private:
    Value As Integer
Public:
''  Constructors and other members
    Declare Operator Not As MyType
    Declare Operator = (MyType rhs) As Boolean
    Declare Operator < (MyType rhs) As Boolean
End Type

Operator MyType.Not As MyType
    Return Type<MyType>(Not This.Value)
End Operator

Operator MyType.= (MyType rhs) As Boolean
    Return This.Value = rhs.Value
End Operator

Operator MyType.< (<yType rhs) As Boolean
    Return This.Value < rhs. Value
End Operator

Discussion

  • Rule

    Rule - 2020-11-06

    Sorry for the typos. (MyType rhs) and (<yType rhs) should be (rhs As MyType).

     

    Last edit: Rule 2020-12-05
  • Jeff Marshall

    Jeff Marshall - 2023-04-01
     

    Related

    Bugs: #902
    Bugs: #903


Log in to post a comment.

MongoDB Logo MongoDB