Skip to content
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

rethrow() -> throw() #43669

Closed
adigitoleo opened this issue Jan 5, 2022 · 6 comments · Fixed by #43674
Closed

rethrow() -> throw() #43669

adigitoleo opened this issue Jan 5, 2022 · 6 comments · Fixed by #43674

Comments

@adigitoleo
Copy link
Contributor

Unless I'm missing something, there is no use of the zero-argument throw() at the moment. Also, ?rethrow discourages using rethrow(e) in favour of throw(e). This is a suggestion to delete/deprecate rethrow and use a zero-argument form of throw() for rethrowing the current error. The motivation is simplification, and to avoid immediately presenting new Julians with caveats (?rethrow). Personally I seem to forget about rethrow every time I return to Julia, because I'm thinking in terms of multiple dispatch and throw() seems more natural. Python's raise also behaves in a similar way: https://docs.python.org/3/reference/simple_stmts.html#index-27

@purna135
Copy link

purna135 commented Jan 5, 2022

Hi, I am new to open source and I want to fix this essue can you give me some suggestions on how to start.

@adigitoleo
Copy link
Contributor Author

@pcm135 Best to wait on some more opinions for this one. This is not a bug but a feature request.

@JeffBezanson
Copy link
Member

This is a reasonable idea, but I think there is a further distinction between throw and rethrow: throw creates a new nested exception, while rethrow continues as if the exception had not been caught. It's technically possible to have throw() = rethrow(), but it's arguably cleaner to give different names to those different behaviors.

@adigitoleo
Copy link
Contributor Author

arguably cleaner to give different names to those different behaviors

Fair enough. Maybe its a docs issue, probably ?throw should point people to rethrow() in that case.

@DilumAluthge
Copy link
Member

It seems reasonable to have the docstring for throw point to rethrow, and also vice versa.

@adigitoleo
Copy link
Contributor Author

Check PR, rethrow already mentions throw so I haven't added it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants