groovy

Overloading divide - method is called "div" not "divide"

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-1
  • Fix Version/s: 1.1-beta-2
  • Component/s: class generator
  • Labels:
    None
  • Number of attachments :
    0

Description

The documents describe overloading the divide operator as adding method divide() to a class.
It is in fact div(). I see this in AsmClassGenerator and AsmClassGenerator2 (not sure where else it needs to change)

For consistency the methods should either be mul() and div() or multiply() and divide(). At the moment they are multiply() and div().

Activity

Hide
Brian Larson added a comment -

div() was chosen to avoid a conflict with BigInteger.divide(). Other methods are consistent with Groovy and therefore do not conflict.

Show
Brian Larson added a comment - div() was chosen to avoid a conflict with BigInteger.divide(). Other methods are consistent with Groovy and therefore do not conflict.
Hide
Guillaume Laforge added a comment -

In a former IRC log session, James decided we should use special method names for method operators (especially for method overloading). All operator methods should be called g$add(), g$xxx(), etc.

We may end up using a particular syntax on the Groovy side, like:

operator + (...) {...}

Show
Guillaume Laforge added a comment - In a former IRC log session, James decided we should use special method names for method operators (especially for method overloading). All operator methods should be called g$add(), g$xxx(), etc. We may end up using a particular syntax on the Groovy side, like: operator + (...) {...}
Hide
Paul King added a comment -

Documentation has been fixed at some point in the past.

Show
Paul King added a comment - Documentation has been fixed at some point in the past.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
10m
Original Estimate - 10 minutes
Remaining:
10m
Remaining Estimate - 10 minutes
Logged:
Not Specified
Time Spent - Not Specified