Does this argument really hold when the IDE alread...
# getting-started
f
Does this argument really hold when the IDE already has these little parameter hints?
k
I turn those hints off, I hate them.
👍 4
v
What if you are reviewing a PR outside of your IDE?
😀 1
5
t
you don’t get the hints in a PR either
😀 1
1
l
As they said: using named params allows you to see them even outside the IDE, or with that option disabled. On top of that, you can change the order in which you’re passing them
f
makes a lot of sense, thanks
is mixing up the ordered considered acceptable practice?
k
I think so, yes.
l
As you name the parameters, it's not a bad practice :)
f
one more thing: Why does the IDE not allow unnamed parameters to the right of named ones, even if they have the original order?
is there any specific reason for that
k
Interesting question, it looks like C# does have this: https://gunnarpeipman.com/csharp-non-trailing-named-arguments/
l
Are you sure?
Let me double check
k
It's in the official 7.2 release notes as well.
l
I was referring to kotlin not allowing it 😄
IDE is not complaining with this
Oh sorry, @Florian mis-read what you wrote
I read the vice-versa
s
Named parameters also allow to override defaults without repeating preceding parameters
s
👍
r
@Florian My guess is because it would be confusing, and could lead to unexpected inconsistencies when refactoring.
l
The problem is which is the next one? The one after the named one? Or the first one left behind before it?
The compiler can’t guess
r
@Luca Nicoletti Or even the one that happens to be at the given position.
Which is why C# imposes a number of limitations (that basically make the feature pointless in my opinion). For example, if you had
Copy code
int Volume(int a, int b, int c) {
    return a * b * c
}
This is illegal:
Copy code
Volume(1, c: 2, 3)
So... what's the point?
l
That’s the same for Kotlin 🙂 You can’t have named parameter if not at latest ones
r
No, C# does allow it. For example, this would be allowed
Copy code
Volume(1, b: 2, 3)
They just impose so many limits on it that it can't really be used for anything beyond glorified comments.
l
The limit is: the named parameter must be in the correct order?
r
Not exactly, but pretty close. For example, this is allowed as well:
Copy code
Volume(b: 1, a: 2, 3)
Basically, non-labeled arguments have to be in the exact position they were declared. And labeled arguments must fill in gaps exactly.
Which is rather un-intuitive if you ask me. You didn't even consider that option when you listed your possibilities of what it could mean. It makes sense once you know the rule, but very few people would guess that rule.
f
very interesting, thanks
👍 1
seems to make sense then