-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lang] Named (Optional) arguments #388
Comments
I'm cool with |
Would it be possible to allow all positional arguments to be used as named arguments? For example:
This may or may not cause problems depending on how currying is done, although I don't think it should be a big issue unless I'm missing something
Then for optional arguments maybe the OCaml-like
Currying for this would be a bit trickier, although perhaps the curried function would somehow be able to maintain the list of optional arguments to be applied at any point before the function gets called
Not sure how a curried function with all optional arguments would be handled though... |
I'm actually working on labeled arguments right now 🙂 I've thought about this! Where it gets a little tricky is making the whole system make sense in respect to required labeled arguments. Without required labeled arguments, it's all fine and your type signatures are actually a bit nicer, since the inferred type of a function like Requiring a label doesn't feel as good. Let's say we use ocaml syntax, and we do But what if we just don't have required labels? What's nice about them is you can guarantee a specific look and feel for your APIs. Anytime someone calls One other change that would need to happen if we allowed any argument to be called by name is forced naming of all arguments. If I were to destructure an argument, I'd need to specify the name of that argument: I'm definitely open to some thoughts here since I think it would be cool to be able to supply any argument by name. I think it'd take quite a bit of workshopping to come up with something cohesive wrt destructuring and not requiring labels on every argument. |
Also hilarious I said this more than two years ago:
I had the same feeling now and have spent a considerable amount of time trying to come up with something better and have so far been unable 😛 |
Hmm, those are all good points you bring up; it seems that there is compromise to be made in each approach although the ones I am most partial to are either
|
This would open up some amazing APIs! I really like the
~something
syntax, but I'm open to suggestions.The text was updated successfully, but these errors were encountered: