On 20.03.2018 16:19, eric.mil...@thomsonreuters.com wrote:

Java syntax for a default method value is:

public@interfaceDelegate{

boolean*interfaces*() defaulttrue;

Is there really a need to introduce another form when the saving is actially 0 characters (colon and equals vs open and close brace)?

class Foo {

    fun truth(): Integer = 42

}

  vs.

class Foo {

    Integer truth() { 42 }

}


I do not think the suggestion was to introduce Kotlin method declaration syntax (Which looks like JavaScript, and, as I've said before imho makes little sense in a statically typed language) in general, but "just" the assignment part instead of giving a code block.


(I always felt that the syntax chosen in Java (and therfore Groovy) for declaring default paramters in annotations is odd: Why does the parameter name need to be given looking like a parmeterless method defintion ? Why do we need a "default" keyword ? Generally speaking, the syntax does not fit well with existing syntax. Having:

public@interfaceDelegate{

boolean*interfaces* =true

would imho have made much more sense, since it looks like a class field initialization (interfaces do not support fields, of course, but in the long run that is a weak reason to go along the route that was choosen).)


What about the difference in named parameters in annotations vs. methods?

@Anno(name = value)

def foo = bar(name: value)

Could the map-entry syntax be supported for annotations to normalize named parameters?


I think the unifying aspect here is assignment to variables/parameters/fields, not naming. Since no one will suggest that we replace the assignment operator "=" in Groovy with ":", I think it would therfore be better to move into the opposite direction, and  replace the mape-entry syntax for named parameters with an assignment syntax (while extending its functionality: https://issues.apache.org/jira/browse/GROOVY-8451) - thereby making it compatible with assignment in general and the definition of default parameters.


Reply via email to