4 ms·
Don't let it get to you. If you're critical of something, someone will always downvote. On the other hand this behavior means that the default value will only
by kubb 5y ago
Don't let it get to you. If you're critical of something, someone will always downvote.
On the other hand this behavior means that the default value will only get computed once, so I guess Guido thought it's useful if that value comes e.g. from an expensive function.
On the other other hand you could achieve that latter behavior with a lazy function even if the arguments were reevaluated every time you call the function.
What do others like Common Lisp and Ruby do here?
- jinwoo68 5y agoIn Common Lisp, default values of optional parameters are evaluated each time (only when the argument is not given of course). They can even reference other arguments that come earlier.