Boo
  1. Boo
  2. BOO-206

Overload assignment operator, and implicit conversion

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.5, 0.9
    • Fix Version/s: 0.9.5
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      Description

      It would be nice to be able to overload the assignment operator, and convert implicitly:

      class myNum:
      public i as int

      def constructor(j as int):
      i = j

      static def op_Assignment(j as int):
      i = j

      static def op_Addition(x as myNum, y as myNum) as myNum:
      return x.i + y.i // becomes return myNum(x.i + y.i)

      x as myNum = 0 // becomes x as myNum = myNum(0)
      x = 4 // becomes x.op_Assignment(4)

        Issue Links

          Activity

          Hide
          Bill Wood added a comment -

          Reviewing the example, and noticed that:

          static def op_Assignment(j as int):
          i = j

          should probably be:

          def op_Assignment(j as int):
          i = j
          return self

          Show
          Bill Wood added a comment - Reviewing the example, and noticed that: static def op_Assignment(j as int): i = j should probably be: def op_Assignment(j as int): i = j return self
          Hide
          Bill Wood added a comment -

          This would be nice too:

          def op_Addition(j as int): // notice its not static
          i = i + j
          return self

          then:

          a += 1 // becomes a.op_Addition(1)
          ++a // becomes a.op_Addition(1)

          Show
          Bill Wood added a comment - This would be nice too: def op_Addition(j as int): // notice its not static i = i + j return self then: a += 1 // becomes a.op_Addition(1) ++a // becomes a.op_Addition(1)

            People

            • Assignee:
              Unassigned
              Reporter:
              Bill Wood
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: