RHEOS.jl icon indicating copy to clipboard operation
RHEOS.jl copied to clipboard

Reconsider the use of @assert

Open akabla opened this issue 4 years ago • 2 comments

Are we using @assert properly? the doc suggests that this should be for debugging rather than validating inputs: https://docs.julialang.org/en/v1/base/base/#Base.@assert

It may be best to move towards the 'error' function or throwing proper exceptions that could be caught by the program. https://scls.gitbooks.io/ljthw/content/_chapters/11-ex8.html

akabla avatar Jun 04 '20 21:06 akabla

Sounds good to me. Yes I think things weren't quite as clear in 0.6 so I got into the wrong habit! The nice thing about assert is (was) that we could have a very clear message about what was wrong, in plain english. So if we want to replace then throwing a custom ErrorException with a clear message, or defining our own clear custom exception is probably the way to go.

Edit: Also, related to the above docs on @assert, we should consider doing testing and benchmarking at higher optimisation levels to see how much of a difference that makes to us (could be significant for example in computation of Mittag-Leffler). If the -O3 flag is beneficial, we should document it. I did play around with it a bit in older versions but I don't remember it having much effect then though.

moustachio-belvedere avatar Jun 05 '20 07:06 moustachio-belvedere

I agree that we should set our own Exception class just for clarity. To get a message out, the 'error' function should also do the job though.

akabla avatar Jun 05 '20 07:06 akabla