Skip to content

Commit

Permalink
Add reference to @assert_op in the style guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-thom committed Nov 13, 2020
1 parent 291d39e commit 0aba3d2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions docs/src/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,22 @@ One exception is the case where one file has all single-line functions.
an exception and terminate the application.
* Do not use try/catch to handle retrieving a potentially-missing key from a
dictionary.
* Use @assert statements to guard against programming errors. Do not use them
after detecting bad user input. Note that they may be compiled out in release
builds.

## Asserts
* Use `@assert` statements to guard against programming errors. Do not use them
after detecting bad user input. An assert tripping should indicate that there
is a bug in the code. Note that they may be compiled out in optimized builds in
the future.
* Consider using `InfrastructureSystems.@assert_op` instead of the standard
`@assert` because it will automatically print the value of the expression.
Unlike the standard `@assert` the Julia compiler will never exclude
`@assert_op` in optimized builds.

```julia
julia> a = 3; b = 4;
julia> @assert_op a == b
ERROR: AssertionError: 3 == 4
```

## Globals

Expand Down

0 comments on commit 0aba3d2

Please sign in to comment.