default the label name to the variable name #3330
Replies: 2 comments
-
Hello! Please see previous discussion as to why this is not suitable for Gleam. In short, APIs must always be intentionally designed in Gleam, and we don't value brevity. |
Beta Was this translation helpful? Give feedback.
0 replies
-
After writting a decent amount of gleam, I'm finding myself with a lot of duplication for adding labeled arguments. Labeled arguments are a big win for making the code more readable and avoiding bugs where you pass the arguments in the wrong order. So, automatic labeled arguments would be great. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am a fan of labels because I think they make the call-site way more readable.
However, I think they also make the function definitions very redundant. Its nice to be able to label arguments with a different name than the variable, but most if the time I prefer to just use the same name.
This results in many function definitions looking like this
Would it make sense to eithier:
Make it so that all parameters have labels, and default it to the variable name
Provide a syntax that will allow function authors to indicate they want to use variable names as label names
fn do_something(*, a, b)
where all arguments after*
are labeled.fn do_something(*, a, c b)
would still be valid, wherea
is labeleda
andb
is labeledc
.Beta Was this translation helpful? Give feedback.
All reactions