Re:Thoughts on Elixir, Phoenix and LiveView after 18 months ...
by Supermancho on Friday August 18, 2023 @06:42AM
(#37173805)
The question was about why not what is allowed as a guard. Perhaps this was not clear amongst the noise.
Re:Thoughts on Elixir, Phoenix and LiveView after 18 months ...
by josevalim on Sunday August 20, 2023 @06:26AM
(#37197801)
Second paragraph of the first link:
> Not all expressions are allowed in guard clauses, but only a handful of them. This is a deliberate choice. This way, Elixir (and Erlang) can make sure that nothing bad happens while executing guards and no mutations happen anywhere. It also allows the compiler to optimize the code related to guards efficiently.
If it can be improved, please let me know.
https://hexdocs.pm/elixir/1.15/patterns-and-guards.html#guar...
Plus the docs lists on the sidebar which custom functions are guards. Examples: https://hexdocs.pm/elixir/1.15/Integer.html#guards