-
Notifications
You must be signed in to change notification settings - Fork 18k
Optional (or default) function arguments #1675
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
Labels
Comments
Optional arguments are often a crutch for poor API design. You tend to think "Oh well, we can always add it later as an optional argument." Or (worse) "Just add it as an optional argument." The result (as demonstrated by many Python programs) is functions that take many optional arguments whose semantics are hard to discern. Go has design goals, which are discussed at length in this article: http://talks.golang.org/2012/splash.article In reading that article, it should become clear why optional arguments are a no-go for Go. If you do not share those goals, then you are probably better off using another language. Sorry. |
I understand the pitfalls of optional arguments. But forbidding them because they allow poor design is not a solution to me. Because when you really need them (and it happens quite often) you must use one of the "tricks" I mentioned in my first post. When you write two or three or more functions that call each other to support every usecase, you write a lot of stupid code. My proposition is just to let the compiler write this code for you. This is not bad design, it's just syntactic sugar. But maybe you are considering it's up to a project like Groovy or CoffeeScript to do this job for us? And finally, I found no argument about this in the link you gave to me :( |
The [email protected] mailing list is a better place for discussions. Labels changed: added restrict-addissuecomment-commit. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by pierre.gotab:
The text was updated successfully, but these errors were encountered: