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

convention for functions that don't assert the result? #265

Open
mimoo opened this issue Jan 23, 2025 · 0 comments
Open

convention for functions that don't assert the result? #265

mimoo opened this issue Jan 23, 2025 · 0 comments

Comments

@mimoo
Copy link
Contributor

mimoo commented Jan 23, 2025

Interestingly in ocaml there's a convention that if your function can raise an exception then it should have _exn at the end (e.g. https://ocaml.janestreet.com/ocaml-core/109.20.00/doc/core/List.html)

Rust sort of had a convention that you should document any function that could panic.

In both cases this was never really asserted by the compiler and so wasn't too useful. But I think these are good ideas.

I'm wondering if it would make sense to have a convention in function naming to distinguish functions that assert the result, or don't assert the result. For example assert_equal asserts that two variables are equal and equal returns a boolean.

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

No branches or pull requests

1 participant