[ 
https://issues.apache.org/jira/browse/GROOVY-8451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16331508#comment-16331508
 ] 

mgroovy commented on GROOVY-8451:
---------------------------------

(An overview over parameter information in Java up to and including 8:

[https://www.beyondjava.net/blog/reading-java-8-method-parameter-named-reflection/]
 )

> Non-Map-Based Named Parameter Support
> -------------------------------------
>
>                 Key: GROOVY-8451
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8451
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: mgroovy
>            Priority: Major
>              Labels: named-parameters
>
> * Groovy should support named parameters as available in many other languages:
> https://en.wikipedia.org/wiki/Named_parameter
> * The suggested syntax and semantics are the ones used by the Kotlin 
> programming language
> https://kotlinlang.org/docs/reference/functions.html#named-arguments
> since 
> ## using the assignment operator to define named parameter values 
> *** Seems a very organic choice in the Java family of languages
> *** Differentiates the syntax clearly from the alternate/existing Groovy map 
> based named parameter support
> ## The design decisions are relatively straightforward
> ## Kotlin syntax is close to Groovy (apart from some odd deviations), so what 
> works there should work in Groovy
> * Features:
> ** Parameters are assigned a value prioritized in the following order:
> ### positional value
> ### named parameter value
> ### default value
> ** Parameters which do not have a default value must be given when calling 
> the method
> ** All non-named parameters must come before named-parameters
> ** Named parameters can be given in any order
> * Example:
> {code}
> void foo(final x0, final x1, final x2 = defVal2, final x3 = defVal3, final x4 
> = defVal4) { /* ... */ }
> // x0 = val0, x1 = val1, x2 = val2, x3 = defVal3, x4 = val4 
> foo(val0, x2 = val2, x4 = val4, x1 = val1) 
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to