[erlang-questions] Reading, Learning, Confused

Edwin Fine erlang-questions_efine@REDACTED
Sat Jul 19 17:10:50 CEST 2008


Sean,

I think it's historical. "orelse" and "andalso" were added to the language
later. I would also be inclined to use the short-circuit ones, but I don't
find myself writing a lot of code that uses "and" and "or" anyway. I might
have written your example as

f(X) when X == 0; 1/X < 2 ->

which gets evaluated from left to right.

On Sat, Jul 19, 2008 at 11:05 AM, Sean Allen <sean@REDACTED>
wrote:

>
> On Jul 19, 2008, at 10:55 AM, Edwin Fine wrote:
>
>  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?
>>
>
> ok i reinstalled and:
>
> Eshell V5.5.5  (abort with ^G)
> 1> X = 0.
> 0
> 2> (X == 0 ) or (1/X > 2).
>
> =ERROR REPORT==== 19-Jul-2008::11:02:12 ===
> Error in process <0.30.0> with exit value:
> {badarith,[{erlang,'/',[1,0]},{erl_eval,do_apply,5},{erl_eval,expr,5},{erl_eval,expr,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
> ** exited: {badarith,[{erlang,'/',[1,0]},
>                      {erl_eval,do_apply,5},
>                      {erl_eval,expr,5},
>                      {erl_eval,expr,5},
>                      {shell,exprs,6},
>                      {shell,eval_loop,3}]} **
> 3> (X == 0 ) orelse (1/X > 2).
> true
>
>
> which makes a lot more sense. i have no idea why or and orelse where the
> same before.
>
> which leaves the question ( after answering a lot of confusion )...
>
> why would you want to 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/4683f902/attachment.htm>


More information about the erlang-questions mailing list