-
Notifications
You must be signed in to change notification settings - Fork 7
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
Rename named return variable in walker closure #21
Comments
To understand why I don't return
Returning the If the walker closure would return The fact that the named return P.S. |
When talking about performance, the user must take care of it by himself, too. So by that, I disagree that the returning error interface is that awful in terms of performance, as in my own usecase I use pre-defined static errors. However I agree that there are more usecases as I've seen by my own, and sometimes error text would be needed to be dynamic, but in this case, the user still needs to make an effort to avoid What about renaming the |
Using
|
By default, walker closure has the following signature:
IDE proposes it every time you're trying to use auto-complete. And I find the named return's name quite inconvenient because of the following reasons:
err
variable is pretty common and is usually meant to carry a value of typeerror
. This sometimes leads to name collisionsexit
orstop
The preferred solution would be to replace bool with the actual error interface, so
jscan.Scan
would return it instead of error with codeErrorCodeCallback
. However, it breaks backward capability, and according to the fact that v2 was released just recently, it definitely won't be implemented just now.So my current solution is to rename it to some of the already mentioned variants:
exit
stop
break_
(seems ugly tbh)I'm going to open a PR after the resolution
The text was updated successfully, but these errors were encountered: