Boo
  1. Boo
  2. BOO-79

use implicit conversion operators

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      Description

      A lot of types in the BCL (System.Decimal for instance) define implicit and explict conversion operators [1].

      Those operators should be used by boo as apropriate for assignments, function argument evaluation (including overloaded operators) and cast expressions.

      More explicitly, the following boo program:

      def x2(value as Decimal):
      return value*2

      print(x2(4))
      d as Decimal = 0

      should be interpreted as:

      def x2(value as Decimal):
      return Decimal.op_Multiply(value, Decimal.op_Implicit(2))

      print(x2(Decimal.op_Implicit(4)))
      d as Decimal = Decimal.op_Implicit(0)

      [1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_10_9_3.asp

        Issue Links

          Activity

          Hide
          Rodrigo B. de Oliveira added a comment -

          leave for later to have a early 0.4 release.

          Show
          Rodrigo B. de Oliveira added a comment - leave for later to have a early 0.4 release.
          Hide
          Doug H added a comment -

          Here's a first stab at implementing this. Lemme know if there are problems. I haven't tested op_Explicit yet.

          Show
          Doug H added a comment - Here's a first stab at implementing this. Lemme know if there are problems. I haven't tested op_Explicit yet.
          Hide
          Doug H added a comment -

          2nd stab fixs bug + adds support for implicit conversion with operator overloading (see 3rd and 4th test cases under tests/testcases/integration/implicit*.boo).

          The patch along with working bin and src builds are here: http://codehaus.org/~dholton/sandbox/
          If it's not there later, also check: http://forge.novell.com/modules/xfmod/project/?boo-contrib

          Show
          Doug H added a comment - 2nd stab fixs bug + adds support for implicit conversion with operator overloading (see 3rd and 4th test cases under tests/testcases/integration/implicit*.boo). The patch along with working bin and src builds are here: http://codehaus.org/~dholton/sandbox/ If it's not there later, also check: http://forge.novell.com/modules/xfmod/project/?boo-contrib
          Hide
          Rodrigo B. de Oliveira added a comment -

          Doug,

          I suggest we create a sandbox area in the repository so you can keep your patches/experiments readily available for people and for merging. What do you think?

          Show
          Rodrigo B. de Oliveira added a comment - Doug, I suggest we create a sandbox area in the repository so you can keep your patches/experiments readily available for people and for merging. What do you think?
          Hide
          Doug H added a comment -

          "I suggest we create a sandbox area in the repository so you can keep your patches/experiments readily available for people and for merging. What do you think?"

          I've been doing that a year and nobody bothers with patching and merging and conflict editing to test them out (not that I blame them). So I'm putting patched builds at novell forge for now for testing.

          Show
          Doug H added a comment - "I suggest we create a sandbox area in the repository so you can keep your patches/experiments readily available for people and for merging. What do you think?" I've been doing that a year and nobody bothers with patching and merging and conflict editing to test them out (not that I blame them). So I'm putting patched builds at novell forge for now for testing.
          Hide
          Doug H added a comment -

          After applying patch, change this line NormalizeTypeAndMemberDefinitions.LeaveMethod:

          if (node.Name.StartsWith("op_"))

          to

          if (node.Name != null && node.Name.StartsWith("op_"))

          Some methods created by ast attributes do not have a name set. At least not until later in the pipeline.

          Show
          Doug H added a comment - After applying patch, change this line NormalizeTypeAndMemberDefinitions.LeaveMethod: if (node.Name.StartsWith("op_")) to if (node.Name != null && node.Name.StartsWith("op_")) Some methods created by ast attributes do not have a name set. At least not until later in the pipeline.
          Hide
          Doug H added a comment -

          This version of the patch is a rewrite. Covers more cases. It converts expressions to use op_Implicit during processmethodbodies instead of emitassembly, and it reduces a lot of code duplication.

          Show
          Doug H added a comment - This version of the patch is a rewrite. Covers more cases. It converts expressions to use op_Implicit during processmethodbodies instead of emitassembly, and it reduces a lot of code duplication.
          Hide
          Doug H added a comment -

          No response on list about this, and patch is over 6 months old.

          Show
          Doug H added a comment - No response on list about this, and patch is over 6 months old.

            People

            • Assignee:
              Unassigned
              Reporter:
              Rodrigo B. de Oliveira
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: