Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-2193

Method invocation that returns no value should evaluate to a known constant instead of null

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.1-beta-3
    • None
    • groovy-runtime
    • None

    Description

      Currently, a method invocation that returns no value evaluates to null. But sometimes it's important to know whether the method actually returned a value or not (e.g. DSLs come to mind). Therefore I propose that method invocations that return no value evaluate to a known constant (e.g. Constants.NO_RETURN_VALUE) instead of null. Apart from making the language more consistent, this would fit in nicely with Groovy's dynamic style, where the return type of a method is generally not known at compile time, and a method might only sometimes return a value.

      Related discussions on the mailing list:
      http://www.nabble.com/Void-the-same-as-null--tf3535287.html#a9867884
      http://www.nabble.com/Ways-to-differentiate-between-methods-that-return-nothing%2C-and-methods-that-return-null-tf4574659.html#a13057848

      Attachments

        Activity

          People

            Unassigned Unassigned
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: