[erlang-questions] Reading, Learning, Confused

Edwin Fine <>
Sat Jul 19 16:55:28 CEST 2008


I cannot imagine of any situation where or and orelse work the same and
reinstalling changes that. Please could you paste your exact code and shell
session, showing the problem? Also, which version of Erlang are you using?

On Sat, Jul 19, 2008 at 10:51 AM, Sean Allen <>
wrote:

>
> On Jul 19, 2008, at 10:47 AM, Edwin Fine wrote:
>
>  You are getting twisted in knots.
>>
>> 1> X =0.
>> 0
>> 2> (X == 0) orelse (1/X > 2).
>> true
>> 3> f().
>> ok
>> 4> X = 1.
>> 1
>> 5> (X == 0) orelse (1/X > 2).
>> false
>> 8> f().
>> 9> X = 0.
>> 0
>> 10> (X == 0) or (1/X > 2).
>> ** exception error: bad argument in an arithmetic expression
>>     in operator  '/'/2
>>        called as 1 / 0
>>
>> So the orelse construct works as advertised. It will not evaluate any
>> expressions after the first false condition and prevents divide by zero.
>>
>
> i need to reinstall because orelse doesnt for me. it works the exact same
> or.
>
> but assuming i get a working install the reason in the example that or
> fails is because of the divide by zero correct?
>
> which raises a new question...
>
> why does or evaluate all the conditions? what purpose does that serve? when
> would you use or instead of orelse?
>
>
>


-- 
The great enemy of the truth is very often not the lie -- deliberate,
contrived and dishonest, but the myth, persistent, persuasive, and
unrealistic. Belief in myths allows the comfort of opinion without the
discomfort of thought.
John F. Kennedy 35th president of US 1961-1963 (1917 - 1963)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080719/22cb8a6d/attachment.html>


More information about the erlang-questions mailing list