Guards Guards – small gotcha in Elixir guard expressions (hauleth.dev) 1 points by hauleth 17d ago ↗ HN
[–] turtleyacht 17d ago ↗ Elixir does not short-circuit its if-then either: if false or true do IO.puts("did not short-circuit (?)") end Maybe because `if' is a macro, the whole expression is sent in for evaluation:https://elixir-lang.readthedocs.io/en/latest/intro/5.html#if... [–] hauleth 10d ago ↗ What do you mean there? What is not short-circuited there? [–] turtleyacht 2d ago ↗ The whole thing `false or true' is sent in for evaluation, so if there is a side-effect function that returns `true', it is executed too. Because Elixir treats it as a macro and not short-circuit.
[–] hauleth 10d ago ↗ What do you mean there? What is not short-circuited there? [–] turtleyacht 2d ago ↗ The whole thing `false or true' is sent in for evaluation, so if there is a side-effect function that returns `true', it is executed too. Because Elixir treats it as a macro and not short-circuit.
[–] turtleyacht 2d ago ↗ The whole thing `false or true' is sent in for evaluation, so if there is a side-effect function that returns `true', it is executed too. Because Elixir treats it as a macro and not short-circuit.
3 comments
[ 5.6 ms ] story [ 18.9 ms ] threadhttps://elixir-lang.readthedocs.io/en/latest/intro/5.html#if...