History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-1467
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: Ken Barclay
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Default method parameters

Created: 18/Aug/06 02:43 AM   Updated: 23/Dec/07 12:25 PM
Component/s: command line processing
Affects Version/s: 1.0-JSR-6
Fix Version/s: 1.5.2

Time Tracking:
Not Specified

Environment: Win XP, JDK1.5.0_06, JSR-06


 Description  « Hide
A method declarator in an interface may include one or more default parameters.
These defaults should apply to only the parameters at the end of the parameter list.
JSR-06 permits them to appear anywhere.

Question: Do defaults in interfaces make sense? Could a class implementing the interface
offer a different default value? This leads to ambiguity.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou - 18/Aug/06 04:20 AM
offering a different default value is possible. But default args shouldn't be allowed in interfaces. It should generate non-abstract instance methods, which is not alllowed to do in an interface. So default args musn't be allowed for interfaces if the method is not static

Andres Almiray - 03/Dec/07 10:37 PM
1.1-final-SNAPSHOT still allows the following
interface Foo {
   def doit( String param = "Groovy", int o )
}

def foo = { p -> p } as Foo

Paul King - 23/Dec/07 06:04 AM
Now gives an error message