Hi,<br><br><div>Guard order don't matter! You are limited to a small set of expressions and BIFs in guards. All of these are guaranteed to be total in the sense that either producing a result or terminating. By not defining a rule for guard order, the compiler is free to reorder guard expressions as it sees fit. It can also cache results of guard expressions, since they won't change during the pattern match evaluation.</div><div><br></div><br><div class="gmail_quote">On Mon Jan 05 2015 at 10:18:37 AM Ivan Uemlianin <<a href="mailto:ivan@llaisdy.com">ivan@llaisdy.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The main thing is ; is applied first, so your guard was like:<br>
<br>
(( N > 0, M > 0, N < 100) ; (M < 100))<br>
<br>
Then the whole single expression is evaluated.<br>
<br>
Ivan<br>
<br>
--<br>
festina lente<br>
<br>
<br>
> On 5 Jan 2015, at 09:04, Martin Koroudjiev <<a href="mailto:mrtndimitrov@gmail.com" target="_blank">mrtndimitrov@gmail.com</a>> wrote:<br>
><br>
> Hi, thanks. So the "and" (,) is evaluated first and since (,) is not<br>
> short circuit all will be replaced with true/false. And then the "or"<br>
> will be evaluated.<br>
><br>
><br>
>> On 1/5/2015 10:57 AM, Ivan Uemlianin wrote:<br>
>> The last is correct according to your guards: M < 100. Perhaps you could try:<br>
>><br>
>> ... when N > 0, M > 0, N < 100;<br>
>> N > 0, M > 0, M < 100 -> ...<br>
>><br>
>> Happy New Year!<br>
>><br>
>> Ivan<br>
>><br>
>> --<br>
>> festina lente<br>
>><br>
>><br>
>>> On 5 Jan 2015, at 08:51, Martin Koroudjiev <<a href="mailto:mrtndimitrov@gmail.com" target="_blank">mrtndimitrov@gmail.com</a>> wrote:<br>
>>><br>
>>> Hello,<br>
>>><br>
>>> First of all - Happy New Year!<br>
>>><br>
>>> Suppose we have a function that accepts 2 integers and we want to react<br>
>>> only when both integers are greater than 0 and one of them is less than 100:<br>
>>><br>
>>> I tried:<br>
>>> (dilbert@Martin-PC)1> F = fun(N, M) when N > 0, M > 0, N < 100; M < 100<br>
>>> -> cool; (_, _) -> not_cool end.<br>
>>> #Fun<erl_eval.12.106461118><br>
>>> (dilbert@Martin-PC)2> F(1,2).<br>
>>> cool<br>
>>> (dilbert@Martin-PC)3> F(1,200).<br>
>>> cool<br>
>>> (dilbert@Martin-PC)4> F(0,200).<br>
>>> not_cool<br>
>>> (dilbert@Martin-PC)5> F(0,50).<br>
>>> cool<br>
>>><br>
>>> The last is not correct.<br>
>>> What is the order of evaluation of the guards? Sadly parentheses are not<br>
>>> allowed in guards.<br>
>>><br>
>>> Best regards,<br>
>>> Martin<br>
>>><br>
>>> ______________________________<u></u>_________________<br>
>>> erlang-questions mailing list<br>
>>> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
>>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
><br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div>