I was recently looking through the standard library and saw the annotation -> !
in some procedures. I did not find any mention of this in the documentation… What does it mean?
1 Like
This marks a procedure as being divergent or having a diverging call, which is to say that it does not return. For example, panic
is divergent and so is libc.exit
. You can find the word diverging
in the compiler to refer to this, and divergent
appears once in the docs of core:c/libc
:
| `<stdnoreturn.h>` | Not applicable, use Odin's divergent return `!` |
It’s not a largely documented feature since it’s not often we write divergent procedures.
4 Likes
Well, then I guessed right, thanks for your reply!
In my opinion, it really needs to be mentioned in the documentation.
If you put defer statement and divergent proc in a same block, the compiler warn you that the defer statement will never executed.
1 Like