jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-2503 MOP 2.0 design inflluencing issues
  • GROOVY-2193

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

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Sub-task Sub-task
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.1-beta-3
  • Fix Version/s: None
  • Component/s: bytecode
  • Labels:
    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

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Randall R Schulz added a comment - 11/Oct/07 5:42 PM

Given the premise, that for some methods it's important to know whether a value was returned or not, should the method not take responsibility and simply return something (specific) or nothing (null)?

Why should the langauge be elaborated to accommodate inattentiveness or carelessnes on the part of the programmer?

Randall Schulz

Show
Randall R Schulz added a comment - 11/Oct/07 5:42 PM Given the premise, that for some methods it's important to know whether a value was returned or not, should the method not take responsibility and simply return something (specific) or nothing (null)? Why should the langauge be elaborated to accommodate inattentiveness or carelessnes on the part of the programmer? Randall Schulz
Hide
Permalink
Peter Niederwieser added a comment - 12/Oct/07 3:51 AM

The problem is that returning nothing is NOT the same as returning null, but Groovy makes a method that returns nothing look like a method that returns null. This has nothing to do with carelessness on the side of the programmer.

Show
Peter Niederwieser added a comment - 12/Oct/07 3:51 AM The problem is that returning nothing is NOT the same as returning null, but Groovy makes a method that returns nothing look like a method that returns null. This has nothing to do with carelessness on the side of the programmer.

People

  • Assignee:
    Unassigned
    Reporter:
    Peter Niederwieser
Vote (0)
Watch (2)

Dates

  • Created:
    11/Oct/07 5:01 PM
    Updated:
    22/Oct/08 10:39 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.