Hacker News new | past | comments | ask | show | jobs | submit login

Because if you're modifying a function and you're adding a new variable to hold some intermediary value, you might accidentally pick a variable name that already exists. If you're in the habit of writing := to signal your intent to create a new variable, that error will probably get caught at compile time rather than being a source of subtle bugs where you trample data needed by something else.

The multi-variable case is trickier, especially because (result, err) is such a common pattern and you neither want to impede the very common case of storing a result into a new variable nor to require a profusion of differently-named variables for errors that are very likely to just get folded anyway. So it allows it if any of the variables are new rather than requiring all. But clearing a large chunk of the bug surface is still much better than not.

(This is only my extrapolated reasoning, of course.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: