JMU-CS / JMU-CS/less-java

Explore required named parameters

Offen
#52 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement proposal
Vorherrschende Sprache
Java
Sterne
6
Forks
7
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

In python a function can define defaults for parameters, and then have the caller assign values to those parameters in the call by referencing the parameter name.

An example:

````python3
def foo(paramA=1):
return paramA + 1

>>> foo(paramA=20)
>>> 21
````

However, in python this is optional, and these named parameters can be left out during a call. They will just assume the default value in the function definition. We could make them implied in LJ with no default declarations in the function definition, but callers must pass all arguments by referencing the parameter names.

This would require the developer to know the names of the parameters, but it would take away all of the guesswork of parameter order. It perhaps goes against the terse philosophy of less java, but I think it might prove to be more user friendly. I haven't searched for any literature on this feature. If anybody knows of any off hand please reference it on this issue.

Discussion is welcome.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.